~ chicken-core (master) e54bcff8f0c3d7b3de55b7b2e68a2b6d28813216
commit e54bcff8f0c3d7b3de55b7b2e68a2b6d28813216
Author: Felix Winkelmann <felix.winkelmann@bevuta.com>
AuthorDate: Tue Sep 15 12:36:31 2026 +0200
Commit: Felix Winkelmann <felix.winkelmann@bevuta.com>
CommitDate: Tue Sep 15 12:36:31 2026 +0200
add ASCII fast path in utf_compare
diff --git a/utf.c b/utf.c
index d699ccf1..684ff407 100644
--- a/utf.c
+++ b/utf.c
@@ -3379,6 +3379,14 @@ C_regparm C_word C_utf_compare(C_word s1, C_word s2, C_word start1, C_word start
C_char *p1 = utf_index(s1, C_unfix(start1));
C_char *p2 = utf_index(s2, C_unfix(start2));
int e, n = C_unfix(len);
+ while(n > 0) {
+ unsigned char b1 = (unsigned char)*p1, b2 = (unsigned char)*p2;
+ if((b1 | b2) & 0x80) break;
+ if(b1 != b2) return C_fix((C_word)b1 - (C_word)b2);
+ ++p1;
+ ++p2;
+ --n;
+ }
while(n--) {
C_u32 c1, c2;
p1 = utf8_decode(p1, &c1, &e);
Trap