summaryrefslogtreecommitdiff
path: root/src
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
parent2d02d39d2cd32e9eb559638865d2746f02c08556 (diff)
Optimize hot loops with direct access, LUTs, and closed-form formulas
Diffstat (limited to 'src')
-rw-r--r--src/compat.h18
-rw-r--r--src/core.c25
-rw-r--r--src/escape.c14
-rw-r--r--src/fastcsi.c41
-rw-r--r--src/input.c27
-rw-r--r--src/internal.h3
-rw-r--r--src/kernels.h11
-rw-r--r--src/osc/clipboard.c33
-rw-r--r--src/osc/dispatch.c3
-rw-r--r--src/palette.c73
-rw-r--r--src/screen.c3
-rw-r--r--src/snapshot.c21
-rw-r--r--src/text.c6
-rw-r--r--src/text_run.c52
14 files changed, 232 insertions, 98 deletions
diff --git a/src/compat.h b/src/compat.h
index a972a0f..c0ae6fa 100644
--- a/src/compat.h
+++ b/src/compat.h
@@ -80,12 +80,11 @@ static inline int term_ctz32(uint32_t x)
{
if (!x)
return 32;
- int n = 0;
- while (!(x & 1u)) {
- x >>= 1;
- n++;
- }
- return n;
+ static const uint8_t de_bruijn[32] = {
+ 0, 1, 28, 2, 29, 14, 24, 3, 30, 22, 20, 15, 25, 17, 4, 8,
+ 31, 27, 13, 23, 21, 19, 16, 7, 26, 12, 18, 6, 11, 5, 10, 9
+ };
+ return (int)de_bruijn[((uint32_t)((x & -x) * 0x077CB531U)) >> 27];
}
static inline int term_clz32(uint32_t x)
{
@@ -101,10 +100,9 @@ static inline int term_clz32(uint32_t x)
}
static inline int term_popcount32(uint32_t x)
{
- int n = 0;
- for (; x; x &= x - 1)
- n++;
- return n;
+ x = x - ((x >> 1) & 0x55555555u);
+ x = (x & 0x33333333u) + ((x >> 2) & 0x33333333u);
+ return (int)((((x + (x >> 4)) & 0x0F0F0F0Fu) * 0x01010101u) >> 24);
}
#endif
diff --git a/src/core.c b/src/core.c
index 12daa72..01218cc 100644
--- a/src/core.c
+++ b/src/core.c
@@ -14,7 +14,19 @@
static uint16_t cluster_presentation(const uint32_t *cps, int len)
{
+ if (len <= 1)
+ return 0;
bool pictographic = unicode_extended_pictographic(cps[0]);
+ if (len == 2) {
+ uint32_t c1 = cps[1];
+ if (c1 == 0xFE0F) return CELL_EMOJI;
+ if (c1 == 0xFE0E) return CELL_TEXT;
+ if (c1 == 0x20E3 || grapheme_regional_indicator(c1) ||
+ (pictographic && (c1 == 0x200D || grapheme_emoji_modifier(c1) ||
+ (c1 >= 0xE0020 && c1 <= 0xE007F))))
+ return CELL_EMOJI;
+ return 0;
+ }
bool emoji = false;
for (int i = 1; i < len; i++) {
if (cps[i] == 0xFE0F)
@@ -320,6 +332,19 @@ void term_sc_tab(struct term *t, int n)
int dir = n >= 0 ? 1 : -1;
int count = n >= 0 ? n : -n;
if (count > t->cols) count = t->cols;
+ if (!t->custom_tabs) {
+ if (dir > 0) {
+ int next = ((t->cursor_x / 8) + count) * 8;
+ t->cursor_x = next < t->cols ? next : t->cols - 1;
+ } else {
+ int prev = t->cursor_x > 0 ? (((t->cursor_x - 1) / 8 - (count - 1)) * 8) : 0;
+ t->cursor_x = prev > 0 ? prev : 0;
+ }
+ t->pending_wrap = false;
+ struct srow *cur = term_row(t, t->cursor_y);
+ if (cur) cur->version++;
+ return;
+ }
while (count-- > 0) {
int x = t->cursor_x + dir;
while (x > 0 && x < t->cols - 1 && !t->tabs[x])
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);
diff --git a/src/fastcsi.c b/src/fastcsi.c
index 416e3dc..dfd2dba 100644
--- a/src/fastcsi.c
+++ b/src/fastcsi.c
@@ -91,17 +91,40 @@ static inline const char *parse_color_sequence(const char *p, const char *end, u
static const char *parse_256color(const char *p, const char *end, uint32_t *color)
{
const char *q = p + 2;
- unsigned v = 0;
- int nd = 0;
- while (q < end && (unsigned char)(*q - '0') <= 9) {
- v = v * 10 + (unsigned char)(*q++ - '0');
- if (++nd > 3)
- return NULL;
+ if (q >= end)
+ return NULL;
+ unsigned char d0 = (unsigned char)(*q - '0');
+ if (d0 > 9)
+ return NULL;
+ q++;
+ if (q < end && *q == 'm') {
+ *color = term_color_index(d0);
+ return q + 1;
+ }
+ if (q >= end)
+ return NULL;
+ unsigned char d1 = (unsigned char)(*q - '0');
+ if (d1 > 9)
+ return NULL;
+ q++;
+ if (q < end && *q == 'm') {
+ *color = term_color_index(d0 * 10 + d1);
+ return q + 1;
}
- if (!nd || q >= end || *q != 'm' || v > 255)
+ if (q >= end)
+ return NULL;
+ unsigned char d2 = (unsigned char)(*q - '0');
+ if (d2 > 9)
return NULL;
- *color = term_color_index(v);
- return q + 1;
+ q++;
+ if (q < end && *q == 'm') {
+ unsigned v = d0 * 100 + d1 * 10 + d2;
+ if (v <= 255) {
+ *color = term_color_index(v);
+ return q + 1;
+ }
+ }
+ return NULL;
}
TERM_NOINLINE
diff --git a/src/input.c b/src/input.c
index 5625825..798ffc0 100644
--- a/src/input.c
+++ b/src/input.c
@@ -37,6 +37,16 @@ static inline void sb_bytes(struct seqbuf *sb, const char *s, size_t len)
static inline void sb_u32(struct seqbuf *sb, uint32_t val)
{
+ if (val < 10) {
+ char c = (char)('0' + val);
+ sb_bytes(sb, &c, 1);
+ return;
+ }
+ if (val < 100) {
+ char s[2] = { (char)('0' + (val / 10)), (char)('0' + (val % 10)) };
+ sb_bytes(sb, s, 2);
+ return;
+ }
char tmp[10];
char *end = tmp + sizeof(tmp);
char *p = end;
@@ -652,16 +662,15 @@ struct term_input_result term_input_encode_mouse(const struct term_mouse_event *
sb_u32(&sb, (uint32_t)(cell.y + 1));
sb_ch(&sb, 'M');
} else if (m->mouse_encoding == TERM_MOUSE_ENC_UTF8) {
- const unsigned values[3] = {
- (unsigned)legacy_code + 32, (unsigned)cell.x + 33,
- (unsigned)cell.y + 33,
- };
sb_bytes(&sb, "\033[M", 3);
- for (int i = 0; i < 3; i++) {
- char tmp[8];
- size_t n = (size_t)utf8_encode(values[i], tmp);
- sb_bytes(&sb, tmp, n);
- }
+ char tmp[8];
+ size_t n;
+ n = (size_t)utf8_encode((unsigned)legacy_code + 32, tmp);
+ sb_bytes(&sb, tmp, n);
+ n = (size_t)utf8_encode((unsigned)cell.x + 33, tmp);
+ sb_bytes(&sb, tmp, n);
+ n = (size_t)utf8_encode((unsigned)cell.y + 33, tmp);
+ sb_bytes(&sb, tmp, n);
} else {
if (legacy_code > 223 || cell.x > 222 || cell.y > 222)
return out;
diff --git a/src/internal.h b/src/internal.h
index 979883e..477210d 100644
--- a/src/internal.h
+++ b/src/internal.h
@@ -205,6 +205,7 @@ struct term {
struct cell *view_row_scratch;
int tabs_cap;
int view_scratch_cap;
+ bool custom_tabs;
char osc_buf[256];
char tcap_name[64];
@@ -347,11 +348,13 @@ static inline struct text_pen term_text_pen(const struct term *t)
static inline void term_tabs_clear(struct term *t)
{
memset(t->tabs, 0, (size_t)t->tabs_cap);
+ t->custom_tabs = true;
}
static inline void term_tabs_default(struct term *t)
{
for (int c = 8; c < t->tabs_cap; c += 8) t->tabs[c] = 1;
+ t->custom_tabs = false;
}
static inline bool term_str_was_truncated(struct term *t)
diff --git a/src/kernels.h b/src/kernels.h
index 45d25b7..57066c0 100644
--- a/src/kernels.h
+++ b/src/kernels.h
@@ -208,9 +208,14 @@ static inline TERM_ALWAYS_INLINE void bytes_copy_small(uint8_t *restrict dst,
memcpy(&b, src + n - 4, 4);
memcpy(dst, &a, 4);
memcpy(dst + n - 4, &b, 4);
- } else {
- for (int k = 0; k < n; k++)
- dst[k] = (uint8_t)src[k];
+ } else if (n >= 2) {
+ uint16_t a, b;
+ memcpy(&a, src, 2);
+ memcpy(&b, src + n - 2, 2);
+ memcpy(dst, &a, 2);
+ memcpy(dst + n - 2, &b, 2);
+ } else if (n == 1) {
+ dst[0] = (uint8_t)src[0];
}
}
diff --git a/src/osc/clipboard.c b/src/osc/clipboard.c
index a5ac59d..4f550ba 100644
--- a/src/osc/clipboard.c
+++ b/src/osc/clipboard.c
@@ -3,21 +3,36 @@
#include <stdlib.h>
#include <string.h>
-static int b64_val(char c)
+static const int8_t b64_lut[256] = {
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, 63,
+ 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -1, -1, -1, -1, -1, -1,
+ -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
+ 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, -1,
+ -1, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
+ 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+};
+
+static inline int b64_val(char c)
{
- if (c >= 'A' && c <= 'Z') return c - 'A';
- if (c >= 'a' && c <= 'z') return c - 'a' + 26;
- if (c >= '0' && c <= '9') return c - '0' + 52;
- if (c == '+') return 62;
- if (c == '/') return 63;
- return -1;
+ return b64_lut[(unsigned char)c];
}
static bool b64_decode(const char *s, size_t n, char *out, size_t *out_len)
{
size_t pad = 0;
- while (pad < n && s[n - pad - 1] == '=')
- pad++;
+ if (n > 0 && s[n - 1] == '=') {
+ pad = (n > 1 && s[n - 2] == '=') ? ((n > 2 && s[n - 3] == '=') ? 3 : 2) : 1;
+ }
n -= pad;
if (pad > 2 || (pad && n % 4 + pad != 4))
return false;
diff --git a/src/osc/dispatch.c b/src/osc/dispatch.c
index 4cf986e..74863ed 100644
--- a/src/osc/dispatch.c
+++ b/src/osc/dispatch.c
@@ -135,8 +135,7 @@ static void osc4_handle(struct term *t, const char *params)
static void osc104_handle(struct term *t, const char *params)
{
if (!*params) {
- for (int i = 0; i < 256; i++)
- term_palette_reset(&t->palette, i);
+ term_palette_reset_all(&t->palette);
return;
}
const char *p = params;
diff --git a/src/palette.c b/src/palette.c
index a8add4e..bfaba6c 100644
--- a/src/palette.c
+++ b/src/palette.c
@@ -133,13 +133,19 @@ static uint32_t *palette_slot(struct term_theme *p, const char *key,
const char *digits = key + 5;
if (!*digits || (*digits == '0' && digits[1]))
return NULL;
- int i = 0;
- for (const char *d = digits; *d; d++) {
- if (*d < '0' || *d > '9')
+ int i;
+ if (!digits[1]) {
+ if (digits[0] < '0' || digits[0] > '9')
return NULL;
- i = i * 10 + (*d - '0');
+ i = digits[0] - '0';
+ } else if (!digits[2]) {
+ if (digits[0] < '0' || digits[0] > '9' || digits[1] < '0' || digits[1] > '9')
+ return NULL;
+ i = (digits[0] - '0') * 10 + (digits[1] - '0');
if (i > 15)
return NULL;
+ } else {
+ return NULL;
}
*fallback = builtin_theme.ansi[i];
return &p->ansi[i];
@@ -166,19 +172,36 @@ bool term_theme_set_key(struct term_theme *p, const char *key, const char *val)
static bool parse_hex_channel(const char *s, size_t len, uint8_t *out)
{
- if (len == 0 || len > 4)
- return false;
- unsigned v = 0;
- for (size_t i = 0; i < len; i++) {
- int d = term_hex_nib(s[i]);
+ if (len == 2) {
+ int d0 = term_hex_nib(s[0]), d1 = term_hex_nib(s[1]);
+ if ((d0 | d1) < 0)
+ return false;
+ *out = (uint8_t)((d0 << 4) | d1);
+ return true;
+ }
+ if (len == 1) {
+ int d = term_hex_nib(s[0]);
if (d < 0)
return false;
- v = (v << 4) | (unsigned)d;
+ *out = (uint8_t)(d * 17);
+ return true;
}
- static const unsigned max_for_len[5] = {0, 15, 255, 4095, 65535};
- unsigned max = max_for_len[len];
- *out = (uint8_t)((unsigned long)v * 255 / max);
- return true;
+ if (len == 4) {
+ int d0 = term_hex_nib(s[0]), d1 = term_hex_nib(s[1]);
+ int d2 = term_hex_nib(s[2]), d3 = term_hex_nib(s[3]);
+ if ((d0 | d1 | d2 | d3) < 0)
+ return false;
+ *out = (uint8_t)((((unsigned)d0 << 12) | ((unsigned)d1 << 8) | ((unsigned)d2 << 4) | (unsigned)d3) * 255 / 65535);
+ return true;
+ }
+ if (len == 3) {
+ int d0 = term_hex_nib(s[0]), d1 = term_hex_nib(s[1]), d2 = term_hex_nib(s[2]);
+ if ((d0 | d1 | d2) < 0)
+ return false;
+ *out = (uint8_t)((((unsigned)d0 << 8) | ((unsigned)d1 << 4) | (unsigned)d2) * 255 / 4095);
+ return true;
+ }
+ return false;
}
static bool parse_fraction(const char *s, size_t len, uint8_t *out)
@@ -224,6 +247,8 @@ static bool parse_fraction(const char *s, size_t len, uint8_t *out)
static const char *skip_leading_ws(const char *s)
{
+ if (*s != ' ' && *s != '\t')
+ return s;
while (*s == ' ' || *s == '\t')
s++;
return s;
@@ -232,6 +257,8 @@ static const char *skip_leading_ws(const char *s)
static size_t rtrimmed_len(const char *s)
{
size_t n = strlen(s);
+ if (n == 0 || (s[n - 1] != ' ' && s[n - 1] != '\t'))
+ return n;
while (n > 0 && (s[n - 1] == ' ' || s[n - 1] == '\t'))
n--;
return n;
@@ -294,15 +321,19 @@ bool term_color_parse(const char *input, uint32_t *out)
}
if (ci != 3)
return false;
- uint8_t c[3];
- for (int k = 0; k < 3; k++) {
- bool ok = intensity
- ? parse_fraction(channels[k], chlens[k], &c[k])
- : parse_hex_channel(channels[k], chlens[k], &c[k]);
- if (!ok)
+ uint8_t c0, c1, c2;
+ if (intensity) {
+ if (!parse_fraction(channels[0], chlens[0], &c0) ||
+ !parse_fraction(channels[1], chlens[1], &c1) ||
+ !parse_fraction(channels[2], chlens[2], &c2))
+ return false;
+ } else {
+ if (!parse_hex_channel(channels[0], chlens[0], &c0) ||
+ !parse_hex_channel(channels[1], chlens[1], &c1) ||
+ !parse_hex_channel(channels[2], chlens[2], &c2))
return false;
}
- *out = term_rgb(c[0], c[1], c[2]);
+ *out = term_rgb(c0, c1, c2);
return true;
}
diff --git a/src/screen.c b/src/screen.c
index fbfebfc..e3f0191 100644
--- a/src/screen.c
+++ b/src/screen.c
@@ -1012,8 +1012,7 @@ struct term *term_new(const struct term_options *opt)
memcpy(t->tcap_name, "wsap_term", sizeof("wsap_term"));
term_tabs_default(t);
t->full_gen = 1;
- for (int j = 0; j < TERM_WIDTH_SLOTS; j++)
- t->text_width.lo[j] = 0xFFFFFFFFu;
+ memset(t->text_width.lo, 0xFF, sizeof(t->text_width.lo));
return t;
}
diff --git a/src/snapshot.c b/src/snapshot.c
index 3869be4..29ed98c 100644
--- a/src/snapshot.c
+++ b/src/snapshot.c
@@ -189,17 +189,26 @@ static bool term_snapshot_update_inner(struct term_snapshot *s, struct term *t)
if (!all && rows > 1) {
int cand_k = 0;
/* Find candidate scroll offset k by checking where top rows moved. */
- for (int p = 0; p < 2 && p < rows - 1 && !cand_k; p++) {
- uint64_t key = new_keys[p];
- if (!key)
- continue;
- for (int k = 1; p + k < rows; k++) {
- if (s->keys[p + k] == key) {
+ uint64_t key0 = new_keys[0];
+ if (key0) {
+ for (int k = 1; k < rows; k++) {
+ if (s->keys[k] == key0) {
cand_k = k;
break;
}
}
}
+ if (!cand_k && rows > 2) {
+ uint64_t key1 = new_keys[1];
+ if (key1) {
+ for (int k = 1; 1 + k < rows; k++) {
+ if (s->keys[1 + k] == key1) {
+ cand_k = k;
+ break;
+ }
+ }
+ }
+ }
if (cand_k > 0) {
int total = rows - cand_k;
diff --git a/src/text.c b/src/text.c
index c68011f..07ade9d 100644
--- a/src/text.c
+++ b/src/text.c
@@ -343,6 +343,12 @@ void term_text_repeat(struct term *t, int count)
{
int screen = t->cols * t->rows;
if (count > screen) count = screen;
+ if (count <= 0 || !t->last_char)
+ return;
+ if (count == 1) {
+ term_sc_print_glyph(t, t->last_char, -1, term_current_flags(t));
+ return;
+ }
for (int j = 0; j < count && t->last_char; j++)
term_sc_print_glyph(t, t->last_char, -1, term_current_flags(t));
}
diff --git a/src/text_run.c b/src/text_run.c
index 3901cbe..9df7ac0 100644
--- a/src/text_run.c
+++ b/src/text_run.c
@@ -53,11 +53,19 @@ static TERM_MAYBE_UNUSED int width_run_find(uint32_t cp)
static TERM_MAYBE_UNUSED uint16_t width_cache_covers(const struct width_cache *wc,
const uint32_t *cp)
{
+ uint32_t lo0 = wc->lo[0], span0 = wc->span[0];
+ uint32_t lo1 = wc->lo[1], span1 = wc->span[1];
+ uint32_t lo2 = wc->lo[2], span2 = wc->span[2];
+ uint32_t lo3 = wc->lo[3], span3 = wc->span[3];
uint16_t covered = 0;
- for (int j = 0; j < TERM_WIDTH_SLOTS; j++)
- for (int l = 0; l < 16; l++)
- if (cp[l] - wc->lo[j] <= wc->span[j])
- covered |= (uint16_t)(1u << l);
+ for (int l = 0; l < 16; l++) {
+ uint32_t c = cp[l];
+ bool hit = ((c - lo0 <= span0) |
+ (c - lo1 <= span1) |
+ (c - lo2 <= span2) |
+ (c - lo3 <= span3));
+ covered |= (uint16_t)(hit << l);
+ }
return covered;
}
@@ -70,10 +78,8 @@ static TERM_MAYBE_UNUSED bool width_cache_extend(struct width_cache *wc, const u
uint8_t k = width_run_class[r];
if (k != 1 && k != 2) return false;
if (k != wc->klass) {
- for (int j = 0; j < TERM_WIDTH_SLOTS; j++) {
- wc->lo[j] = 0xFFFFFFFFu;
- wc->span[j] = 0;
- }
+ memset(wc->lo, 0xFF, sizeof(wc->lo));
+ memset(wc->span, 0, sizeof(wc->span));
wc->klass = k;
wc->next = 0;
}
@@ -140,10 +146,14 @@ TERM_TARGET_AVX512
static inline struct width_ranges width_ranges_load(const struct width_cache *wc)
{
struct width_ranges r;
- for (int j = 0; j < TERM_WIDTH_SLOTS; j++) {
- r.lo[j] = _mm512_set1_epi32((int)wc->lo[j]);
- r.span[j] = _mm512_set1_epi32((int)wc->span[j]);
- }
+ r.lo[0] = _mm512_set1_epi32((int)wc->lo[0]);
+ r.span[0] = _mm512_set1_epi32((int)wc->span[0]);
+ r.lo[1] = _mm512_set1_epi32((int)wc->lo[1]);
+ r.span[1] = _mm512_set1_epi32((int)wc->span[1]);
+ r.lo[2] = _mm512_set1_epi32((int)wc->lo[2]);
+ r.span[2] = _mm512_set1_epi32((int)wc->span[2]);
+ r.lo[3] = _mm512_set1_epi32((int)wc->lo[3]);
+ r.span[3] = _mm512_set1_epi32((int)wc->span[3]);
return r;
}
@@ -519,16 +529,14 @@ static inline int decode_3byte_quads(uint64_t **dst_io, const char *buf, int len
uint8_t k2 = unicode_fast_class[cp[2]], k3 = unicode_fast_class[cp[3]];
if (!k0 || !k1 || !k2 || !k3)
break;
- const uint8_t k[4] = { k0, k1, k2, k3 };
- for (int j = 0; j < 4; j++) {
- if (k[j] == 1) {
- dst = store_cell(dst, b, cp[j]);
- cx++;
- } else {
- dst = store_cell_wide(dst, b, cp[j]);
- cx += 2;
- }
- }
+ if (k0 == 1) { dst = store_cell(dst, b, cp[0]); cx++; }
+ else { dst = store_cell_wide(dst, b, cp[0]); cx += 2; }
+ if (k1 == 1) { dst = store_cell(dst, b, cp[1]); cx++; }
+ else { dst = store_cell_wide(dst, b, cp[1]); cx += 2; }
+ if (k2 == 1) { dst = store_cell(dst, b, cp[2]); cx++; }
+ else { dst = store_cell_wide(dst, b, cp[2]); cx += 2; }
+ if (k3 == 1) { dst = store_cell(dst, b, cp[3]); cx++; }
+ else { dst = store_cell_wide(dst, b, cp[3]); cx += 2; }
*last = cp[3];
i += 12;
}