mirror of
https://github.com/ruby/ruby.git
synced 2025-08-15 13:39:04 +02:00
Merge f774071fc7
into a04555c8ab
This commit is contained in:
commit
9d2524fed8
1 changed files with 13 additions and 3 deletions
16
string.c
16
string.c
|
@ -4422,7 +4422,6 @@ static VALUE
|
|||
str_casecmp_p(VALUE str1, VALUE str2)
|
||||
{
|
||||
rb_encoding *enc;
|
||||
VALUE folded_str1, folded_str2;
|
||||
VALUE fold_opt = sym_fold;
|
||||
|
||||
enc = rb_enc_compatible(str1, str2);
|
||||
|
@ -4430,8 +4429,19 @@ str_casecmp_p(VALUE str1, VALUE str2)
|
|||
return Qnil;
|
||||
}
|
||||
|
||||
folded_str1 = rb_str_downcase(1, &fold_opt, str1);
|
||||
folded_str2 = rb_str_downcase(1, &fold_opt, str2);
|
||||
if (ENC_CODERANGE(str1) == ENC_CODERANGE_7BIT &&
|
||||
ENC_CODERANGE(str2) == ENC_CODERANGE_7BIT) {
|
||||
static const long break_even_point = 120;
|
||||
long len1 = RSTRING_LEN(str1);
|
||||
if (len1 != RSTRING_LEN(str2)) return Qfalse;
|
||||
if (len1 < break_even_point) {
|
||||
VALUE cmp = str_casecmp(str1, str2);
|
||||
return RBOOL(cmp == INT2FIX(0));
|
||||
}
|
||||
}
|
||||
|
||||
VALUE folded_str1 = rb_str_downcase(1, &fold_opt, str1);
|
||||
VALUE folded_str2 = rb_str_downcase(1, &fold_opt, str2);
|
||||
|
||||
return rb_str_eql(folded_str1, folded_str2);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue