aboutsummaryrefslogtreecommitdiff
path: root/stdlib/text.c
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2024-12-07 15:59:37 -0500
committerBruce Hill <bruce@bruce-hill.com>2024-12-07 15:59:37 -0500
commita201939a8150bc4c2f221925797ea2751c74b77c (patch)
tree26fee4ec601319fd8771435087931023e393fe92 /stdlib/text.c
parent683b0f5141ad21914d77cd4b4b81e7e2161f90f3 (diff)
Use likely()/unlikely() macros and a few bugfixes for integers
Diffstat (limited to 'stdlib/text.c')
-rw-r--r--stdlib/text.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/stdlib/text.c b/stdlib/text.c
index beea8ff8..f4789ff0 100644
--- a/stdlib/text.c
+++ b/stdlib/text.c
@@ -187,10 +187,10 @@ public int32_t get_synthetic_grapheme(const ucs4_t *codepoints, int64_t utf32_le
// that begin with *prefix* modifiers, so we gotta check for that case:
synthetic_graphemes[-grapheme_id-1].main_codepoint = length_prefixed[1];
for (ucs4_t i = 0; i < utf32_len; i++) {
- if (!__builtin_expect(uc_is_property_prepended_concatenation_mark(length_prefixed[1+i]), 0)) {
- synthetic_graphemes[-grapheme_id-1].main_codepoint = length_prefixed[1+i];
- break;
- }
+ if (unlikely(uc_is_property_prepended_concatenation_mark(length_prefixed[1+i])))
+ continue;
+ synthetic_graphemes[-grapheme_id-1].main_codepoint = length_prefixed[1+i];
+ break;
}
// Cleanup from unicode API:
@@ -367,7 +367,7 @@ static Text_t concat2(Text_t a, Text_t b)
if (a.length == 0) return b;
if (b.length == 0) return a;
- if (__builtin_expect(is_concat_stable(a, b), 1))
+ if (likely(is_concat_stable(a, b)))
return concat2_assuming_safe(a, b);
// Do full normalization of the last/first characters
@@ -419,7 +419,7 @@ public Text_t Text$_concat(int n, Text_t items[n])
if (items[i].length == 0)
continue;
- if (i > 0 && !__builtin_expect(is_concat_stable(items[i-1], items[i]), 1)) {
+ if (i > 0 && unlikely(!is_concat_stable(items[i-1], items[i]))) {
// Oops, guess this wasn't stable for concatenation, let's break it
// up into subtasks:
return concat2(ret, Text$_concat(n-i, &items[i]));