diff options
| author | Daniel Eklöf <daniel@ekloef.se> | 2020-06-09 15:31:28 +0000 |
|---|---|---|
| committer | Daniel Eklöf <daniel@ekloef.se> | 2020-06-09 15:31:28 +0000 |
| commit | 9df7e8fa07a234b6a7b33b52310e7ddaa884850f (patch) | |
| tree | e57fc32d5980881217487384ed37a8740c5f99a9 | |
| parent | vt: utf8-print: check width == 0 first, when deciding whether to do combining (diff) | |
term: print_insert: early return
| -rw-r--r-- | terminal.c | 23 |
1 files changed, 12 insertions, 11 deletions
@@ -2353,19 +2353,20 @@ print_insert(struct terminal *term, int width) { assert(width > 0); - if (unlikely(term->insert_mode)) { - struct row *row = term->grid->cur_row; - const size_t move_count = max(0, term->cols - term->grid->cursor.point.col - width); + if (likely(!term->insert_mode)) + return; + + struct row *row = term->grid->cur_row; + const size_t move_count = max(0, term->cols - term->grid->cursor.point.col - width); - memmove( - &row->cells[term->grid->cursor.point.col + width], - &row->cells[term->grid->cursor.point.col], - move_count * sizeof(struct cell)); + memmove( + &row->cells[term->grid->cursor.point.col + width], + &row->cells[term->grid->cursor.point.col], + move_count * sizeof(struct cell)); - /* Mark moved cells as dirty */ - for (size_t i = term->grid->cursor.point.col + width; i < term->cols; i++) - row->cells[i].attrs.clean = 0; - } + /* Mark moved cells as dirty */ + for (size_t i = term->grid->cursor.point.col + width; i < term->cols; i++) + row->cells[i].attrs.clean = 0; } void |
