We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 6190e8a commit f774071Copy full SHA for f774071
string.c
@@ -4452,8 +4452,13 @@ str_casecmp_p(VALUE str1, VALUE str2)
4452
4453
if (ENC_CODERANGE(str1) == ENC_CODERANGE_7BIT &&
4454
ENC_CODERANGE(str2) == ENC_CODERANGE_7BIT) {
4455
- VALUE cmp = str_casecmp(str1, str2);
4456
- return RBOOL(cmp == INT2FIX(0));
+ static const long break_even_point = 120;
+ 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
+ }
4462
}
4463
4464
VALUE folded_str1 = rb_str_downcase(1, &fold_opt, str1);
0 commit comments