summaryrefslogtreecommitdiff
path: root/src/escape.c
diff options
context:
space:
mode:
authorBerke Güzel <wenekar1@gmail.com>2026-10-13 19:22:05 +0300
committerBerke Güzel <wenekar1@gmail.com>2026-10-13 19:22:05 +0300
commit01e1c61e9fcf4a0b0164a7fe5395a209a50f6905 (patch)
tree1f1eb33e49eab338650a42e8f602af75d8d28a24 /src/escape.c
parent2d02d39d2cd32e9eb559638865d2746f02c08556 (diff)
Optimize hot loops with direct access, LUTs, and closed-form formulas
Diffstat (limited to 'src/escape.c')
-rw-r--r--src/escape.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/escape.c b/src/escape.c
index fc254af..1e56d77 100644
--- a/src/escape.c
+++ b/src/escape.c
@@ -293,6 +293,7 @@ static void restore_deccir(struct term *t, const char *p, const char *end)
static void restore_dectabsr(struct term *t, const char *p, const char *end)
{
term_tabs_clear(t);
+ t->custom_tabs = true;
int stop = 0, any = 0;
for (; p < end; p++) {
if (*p >= '0' && *p <= '9') {
@@ -317,9 +318,7 @@ static bool dcs_reserve(struct term *t, size_t extra)
return true;
if (t->dcs_cap >= TERM_OSC_MAX)
return false;
- size_t cap = t->dcs_cap ? t->dcs_cap : 256;
- while (cap < need && cap < TERM_OSC_MAX)
- cap *= 2;
+ size_t cap = term_grow_cap(t->dcs_cap ? t->dcs_cap : 256, need);
if (cap > TERM_OSC_MAX)
cap = TERM_OSC_MAX;
char *p = realloc(t->dcs_buf, cap);
@@ -726,8 +725,12 @@ static inline TERM_ALWAYS_INLINE void dispatch_csi(struct term *t, const struct
term_sc_tab(t, csi->final == 'I' ? csi_count(csi) : -csi_count(csi));
break;
case 'g':
- if (csi->params[0] == 0) t->tabs[t->cursor_x] = 0;
- else if (csi->params[0] == 3) term_tabs_clear(t);
+ if (csi->params[0] == 0) {
+ t->tabs[t->cursor_x] = 0;
+ t->custom_tabs = true;
+ } else if (csi->params[0] == 3) {
+ term_tabs_clear(t);
+ }
break;
case 'W':
if (csi->prefix == '?' && csi->params[0] == 5) {
@@ -871,6 +874,7 @@ static void dispatch_esc(struct term *t, unsigned char ch)
break;
case 'H':
t->tabs[t->cursor_x] = 1;
+ t->custom_tabs = true;
break;
case 'c':
if (t->alternate) term_screen_set_alternate(t, false);