grid: reflow: no need to check for combining characters

Since we no longer call wcwidth(), we don’t need the base character.
This commit is contained in:
Daniel Eklöf 2021-05-15 00:12:51 +02:00
parent 8e05f42a1c
commit a5ec26ccc9
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F

31
grid.c
View file

@ -491,6 +491,8 @@ grid_resize_and_reflow(
/* Walk current line of the old grid */
for (int c = 0; c < old_cols; c++) {
const struct cell *old_cell = &old_row->cells[c];
wchar_t wc = old_cell->wc;
/* Check if this cell is one of the tracked cells */
bool is_tracking_point = false;
@ -512,7 +514,7 @@ grid_resize_and_reflow(
}
}
if (old_row->cells[c].wc == 0 && !is_tracking_point) {
if (wc == 0 && !is_tracking_point) {
empty_count++;
continue;
}
@ -529,35 +531,22 @@ grid_resize_and_reflow(
if (new_col_idx + 1 > new_cols)
line_wrap();
new_row->cells[new_col_idx] = old_row->cells[c - empty_count + i];
size_t idx = c - empty_count + i;
new_row->cells[new_col_idx].wc = 0;
new_row->cells[new_col_idx].attrs = old_row->cells[idx].attrs;
new_row->cells[new_col_idx].attrs.clean = 1;
new_col_idx++;
}
empty_count = 0;
wchar_t wc = old_row->cells[c].wc;
if (wc >= CELL_COMB_CHARS_LO &&
wc < (CELL_COMB_CHARS_LO + compose_count))
{
wc = composed[wc - CELL_COMB_CHARS_LO].base;
}
const struct cell *old_cell = &old_row->cells[c];
wc = old_cell->wc;
if (wc == CELL_SPACER)
continue;
if (wc >= CELL_COMB_CHARS_LO &&
wc < (CELL_COMB_CHARS_LO + compose_count))
{
wc = composed[wc - CELL_COMB_CHARS_LO].base;
}
if (wc < CELL_SPACER &&
c + 1 < old_cols &&
old_row->cells[c + 1].wc > CELL_SPACER)
if (unlikely(wc < CELL_SPACER &&
c + 1 < old_cols &&
old_row->cells[c + 1].wc > CELL_SPACER))
{
int width = old_row->cells[c + 1].wc - CELL_SPACER + 1;
assert(wcwidth(wc) == width);