diff options
| author | Daniel Eklöf <daniel@ekloef.se> | 2019-11-17 17:52:27 +0000 |
|---|---|---|
| committer | Daniel Eklöf <daniel@ekloef.se> | 2019-11-17 17:52:27 +0000 |
| commit | 9902a5732f9d3d99955f3c7bf09ebc8db4bd1f82 (patch) | |
| tree | bfb3f8a5014131babca701f4c4276fd0a1dd8138 /csi.c | |
| parent | Revert "term: new function: term_autowrap()" (diff) | |
term: try to improve on a performance regression
When support was added for DECOM (absolute/relative row addressing), a
small but noticeable (~3.5%) performance regression was introduced.
Try to improve the situation by simplifying the relative-to-absolute
conversion; only the row needs to be transformed.
Diffstat (limited to 'csi.c')
| -rw-r--r-- | csi.c | 20 |
1 files changed, 9 insertions, 11 deletions
@@ -330,9 +330,9 @@ csi_dispatch(struct terminal *term, uint8_t final) case 'd': { /* VPA - vertical line position absolute */ - struct coord new_cursor = term_cursor_rel_to_abs( - term, vt_param_get(term, 0, 1) - 1, term->cursor.point.col); - term_cursor_to(term, new_cursor.row, new_cursor.col); + int rel_row = vt_param_get(term, 0, 1) - 1; + int row = term_row_rel_to_abs(term, rel_row); + term_cursor_to(term, row, term->cursor.point.col); break; } @@ -399,20 +399,18 @@ csi_dispatch(struct terminal *term, uint8_t final) case '`': case 'G': { /* Cursor horizontal absolute */ - struct coord new_cursor = term_cursor_rel_to_abs( - term, term->cursor.point.row, vt_param_get(term, 0, 1) - 1); - term_cursor_to(term, new_cursor.row, new_cursor.col); + int col = min(vt_param_get(term, 0, 1), term->cols) - 1; + term_cursor_to(term, term->cursor.point.row, col); break; } case 'f': case 'H': { /* Move cursor */ - struct coord new_cursor = term_cursor_rel_to_abs( - term, - vt_param_get(term, 0, 1) - 1, - vt_param_get(term, 1, 1) - 1); - term_cursor_to(term, new_cursor.row, new_cursor.col); + int rel_row = vt_param_get(term, 0, 1) - 1; + int row = term_row_rel_to_abs(term, rel_row); + int col = min(vt_param_get(term, 1, 1), term->cols) - 1; + term_cursor_to(term, row, col); break; } |
