Drop val access to CPUCell

Allows us to increase CPUCell beyond 8 bytes if needed
This commit is contained in:
Kovid Goyal 2024-11-23 13:38:50 +05:30
parent 383e1f8f57
commit 21871dcd58
No known key found for this signature in database
GPG key ID: 06BC317B515ACE7C
4 changed files with 6 additions and 7 deletions

View file

@ -568,7 +568,7 @@ set_text(Line* self, PyObject *args) {
color_type dfg = cursor->decoration_fg & COL_MASK;
for (index_type i = cursor->x; offset < limit && i < self->xnum; i++, offset++) {
self->cpu_cells[i].val = 0;
self->cpu_cells[i] = (CPUCell){0};
self->cpu_cells[i].ch_or_idx = PyUnicode_READ(kind, buf, offset);
self->gpu_cells[i].attrs = attrs;
self->gpu_cells[i].fg = fg;
@ -684,7 +684,7 @@ line_get_char(Line *self, index_type at) {
}
void
static void
line_set_char(Line *self, unsigned int at, uint32_t ch, Cursor *cursor, hyperlink_id_type hyperlink_id) {
GPUCell *g = self->gpu_cells + at;
if (cursor != NULL) {
@ -694,7 +694,7 @@ line_set_char(Line *self, unsigned int at, uint32_t ch, Cursor *cursor, hyperlin
g->decoration_fg = cursor->decoration_fg & COL_MASK;
}
CPUCell *c = self->cpu_cells + at;
c->val = 0;
*c = (CPUCell){0};
cell_set_char(c, ch);
c->hyperlink_id = hyperlink_id;
if (OPT(underline_hyperlinks) == UNDERLINE_ALWAYS && hyperlink_id) {

View file

@ -81,9 +81,9 @@ typedef union CPUCell {
};
struct {
char_type ch_and_idx: sizeof(char_type) * 8;
char_type : sizeof(char_type) * 8;
char_type : sizeof(hyperlink_id_type) * 8;
char_type : 16;
};
uint64_t val;
} CPUCell;
static_assert(sizeof(CPUCell) == sizeof(uint64_t), "Fix the ordering of CPUCell");

View file

@ -69,7 +69,6 @@ typedef Line*(get_line_func)(void *, int);
void line_clear_text(Line *self, unsigned int at, unsigned int num, char_type ch);
void line_apply_cursor(Line *self, const Cursor *cursor, unsigned int at, unsigned int num, bool clear_char);
char_type line_get_char(Line *self, index_type at);
void line_set_char(Line *, unsigned int , uint32_t , Cursor *, hyperlink_id_type);
index_type line_url_start_at(Line *self, index_type x);
index_type line_url_end_at(Line *self, index_type x, bool, char_type, bool, bool, index_type);
bool line_startswith_url_chars(Line*, bool);

View file

@ -769,7 +769,7 @@ halve_multicell_width(Screen *self, index_type x_, index_type y_) {
Line *line = range_line_(self, y); cp = line->cpu_cells; gp = line->gpu_cells;
for (index_type x = 0; x < half_x_limit; x++) cp[x].ch_or_idx = idx;
for (index_type x = half_x_limit; x < x_limit; x++) {
cp[x].val = 0; clear_sprite_position(gp[x]);
cp[x] = (CPUCell){0}; clear_sprite_position(gp[x]);
}
if (y > -1) linebuf_mark_line_dirty(self->linebuf, y);
}