mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-03-23 05:33:57 -04:00
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.
This commit is contained in:
parent
cf75528e86
commit
9902a5732f
3 changed files with 17 additions and 29 deletions
24
terminal.c
24
terminal.c
|
|
@ -995,28 +995,19 @@ term_erase(struct terminal *term, const struct coord *start, const struct coord
|
|||
erase_cell_range(term, grid_row(term->grid, end->row), 0, end->col);
|
||||
}
|
||||
|
||||
struct coord
|
||||
term_cursor_rel_to_abs(const struct terminal *term, int row, int col)
|
||||
int
|
||||
term_row_rel_to_abs(const struct terminal *term, int row)
|
||||
{
|
||||
switch (term->origin) {
|
||||
case ORIGIN_ABSOLUTE:
|
||||
return (struct coord) {
|
||||
.col = min(col, term->cols - 1),
|
||||
.row = min(row, term->rows - 1),
|
||||
};
|
||||
break;
|
||||
return min(row, term->rows - 1);
|
||||
|
||||
case ORIGIN_RELATIVE: {
|
||||
return (struct coord) {
|
||||
.col = min(col, term->cols - 1),
|
||||
.row = min(row + term->scroll_region.start, term->rows - 1),
|
||||
};
|
||||
break;
|
||||
}
|
||||
case ORIGIN_RELATIVE:
|
||||
return min(row + term->scroll_region.start, term->scroll_region.end - 1);
|
||||
}
|
||||
|
||||
assert(false);
|
||||
return (struct coord){-1, -1};
|
||||
return -1;
|
||||
}
|
||||
|
||||
void
|
||||
|
|
@ -1036,8 +1027,7 @@ term_cursor_to(struct terminal *term, int row, int col)
|
|||
void
|
||||
term_cursor_home(struct terminal *term)
|
||||
{
|
||||
struct coord new_cursor = term_cursor_rel_to_abs(term, 0, 0);
|
||||
term_cursor_to(term, new_cursor.row, new_cursor.col);
|
||||
term_cursor_to(term, term_row_rel_to_abs(term, 0), 0);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue