diff options
| author | Berke Güzel <wenekar1@gmail.com> | 2026-10-14 14:36:22 +0300 |
|---|---|---|
| committer | Berke Güzel <wenekar1@gmail.com> | 2026-10-14 14:36:22 +0300 |
| commit | 4be63ed8cd2eb1c4861f0ab287f24ea695fd671e (patch) | |
| tree | e8cb9953cffc52277ae25804afbaf5888acc089a /src/core.h | |
| parent | d5b5baf119a514731a2e73f36a50ac94b33f9a0e (diff) | |
Optimize term_feed scalar dispatch, branchless range search, and invalid subparts
Diffstat (limited to 'src/core.h')
| -rw-r--r-- | src/core.h | 33 |
1 files changed, 33 insertions, 0 deletions
@@ -30,6 +30,39 @@ static inline void sc_print_ascii(struct term *t, const char *s, int n); /* Print one glyph (single codepoint or cluster handle). */ void term_sc_print_glyph(struct term *t, uint32_t cp, int width, uint16_t flags); +static inline void sc_print_cell(struct term *t, uint32_t cp, int width, uint16_t flags) +{ + if (TERM_EXPECT(width == 1 && !t->pending_wrap && !t->insert_mode && + !t->lr_margin_mode && t->cursor_x < t->cols, 1)) { + struct srow *srow = term_row(t, t->cursor_y); + int cx = t->cursor_x; + int len = srow->len; + if (TERM_EXPECT(srow->kind == ROW_CELLS && cx <= len, 1)) { + struct cell *row = srow->cells; + if (TERM_EXPECT(!((cx < len && (row[cx].flags & CELL_TRAIL)) || + (cx + 1 < len && (row[cx + 1].flags & CELL_TRAIL))), 1)) { + row[cx] = (struct cell){cp, + t->inverse ? t->cur_bg : t->cur_fg, + t->inverse ? t->cur_fg : t->cur_bg, + flags, t->cur_link}; + t->last_char = cp; + cx++; + if (cx > len) srow->len = (uint16_t)cx; + srow->version++; + if (cx < t->cols) { + t->cursor_x = cx; + t->pending_wrap = false; + } else { + t->cursor_x = t->cols - 1; + t->pending_wrap = t->autowrap; + } + return; + } + } + } + term_sc_print_glyph(t, cp, width, flags); +} + /* Extend the last printed glyph into a grapheme cluster. */ bool term_sc_extend_cluster(struct term *t, uint32_t cp, int klass); |
