mirror of
https://github.com/kovidgoyal/kitty
synced 2026-06-06 01:05:48 +02:00
Do not call monotonic() when changing cursor position
monotonic() is extremely slow. This call was halving the CSI parsing speed benchmark. Instead we use the time at which parsing of the current input chunk was started. This should be within a few microseconds and accurate enough for the cursor trail for which it is used.
This commit is contained in:
@@ -1805,7 +1805,7 @@ screen_cursor_position(Screen *self, unsigned int line, unsigned int column) {
|
||||
line += self->margin_top;
|
||||
line = MAX(self->margin_top, MIN(line, self->margin_bottom));
|
||||
}
|
||||
self->cursor->position_changed_by_client_at = monotonic();
|
||||
self->cursor->position_changed_by_client_at = self->parsing_at;
|
||||
self->cursor->x = column; self->cursor->y = line;
|
||||
screen_ensure_bounds(self, false, in_margins);
|
||||
}
|
||||
|
||||
@@ -173,6 +173,7 @@ typedef struct {
|
||||
} paused_rendering;
|
||||
CharsetState charset;
|
||||
ListOfChars *lc;
|
||||
monotonic_t parsing_at;
|
||||
} Screen;
|
||||
|
||||
|
||||
|
||||
@@ -1417,6 +1417,7 @@ static void
|
||||
run_worker(void *p, ParseData *pd, bool flush) {
|
||||
Screen *screen = (Screen*)p;
|
||||
PS *self = (PS*)screen->vt_parser->state;
|
||||
screen->parsing_at = pd->now;
|
||||
with_lock {
|
||||
self->read.sz += self->write.pending; self->write.pending = 0;
|
||||
pd->has_pending_input = self->read.pos < self->read.sz;
|
||||
|
||||
Reference in New Issue
Block a user