Skip to content

Commit f774071

Browse files
sferiknobu
andcommitted
Only implement this optimization for strings under 120 characters
Co-authored-by: Nobuyoshi Nakada <nobu.nakada@gmail.com>
1 parent 6190e8a commit f774071

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

string.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4452,8 +4452,13 @@ str_casecmp_p(VALUE str1, VALUE str2)
44524452

44534453
if (ENC_CODERANGE(str1) == ENC_CODERANGE_7BIT &&
44544454
ENC_CODERANGE(str2) == ENC_CODERANGE_7BIT) {
4455-
VALUE cmp = str_casecmp(str1, str2);
4456-
return RBOOL(cmp == INT2FIX(0));
4455+
static const long break_even_point = 120;
4456+
long len1 = RSTRING_LEN(str1);
4457+
if (len1 != RSTRING_LEN(str2)) return Qfalse;
4458+
if (len1 < break_even_point) {
4459+
VALUE cmp = str_casecmp(str1, str2);
4460+
return RBOOL(cmp == INT2FIX(0));
4461+
}
44574462
}
44584463

44594464
VALUE folded_str1 = rb_str_downcase(1, &fold_opt, str1);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy