ruby-changes:43234
From: duerst <ko1@a...>
Date: Tue, 7 Jun 2016 16:44:24 +0900 (JST)
Subject: [ruby-changes:43234] duerst:r55308 (trunk): * string.c (rb_str_downcase_bang): Switch to use primitive except if
duerst 2016-06-07 16:44:19 +0900 (Tue, 07 Jun 2016) New Revision: 55308 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=55308 Log: * string.c (rb_str_downcase_bang): Switch to use primitive except if conversion can be done ASCII-only. Modified files: trunk/ChangeLog trunk/string.c Index: string.c =================================================================== --- string.c (revision 55307) +++ string.c (revision 55308) @@ -5948,11 +5948,7 @@ rb_str_downcase_bang(int argc, VALUE *ar https://github.com/ruby/ruby/blob/trunk/string.c#L5948 enc = STR_ENC_GET(str); rb_str_check_dummy_enc(enc); s = RSTRING_PTR(str); send = RSTRING_END(str); - if (rb_enc_unicode_p(enc)) { - str_shared_replace(str, rb_str_casemap(str, &flags, enc)); - modify = ONIGENC_CASE_MODIFIED & flags; - } - else if (single_byte_optimizable(str)) { + if (!(flags&ONIGENC_CASE_FOLD_TURKISH_AZERI) && ENC_CODERANGE(str)==ENC_CODERANGE_7BIT) { while (s < send) { unsigned int c = *(unsigned char*)s; @@ -5964,29 +5960,8 @@ rb_str_downcase_bang(int argc, VALUE *ar https://github.com/ruby/ruby/blob/trunk/string.c#L5960 } } else { - int ascompat = rb_enc_asciicompat(enc); - - while (s < send) { - unsigned int c; - int n; - - if (ascompat && (c = *(unsigned char*)s) < 0x80) { - if (rb_enc_isascii(c, enc) && 'A' <= c && c <= 'Z') { - *s = 'a' + (c - 'A'); - modify = 1; - } - s++; - } - else { - c = rb_enc_codepoint_len(s, send, &n, enc); - if (rb_enc_isupper(c, enc)) { - /* assuming toupper returns codepoint with same size */ - rb_enc_mbcput(rb_enc_tolower(c, enc), s, enc); - modify = 1; - } - s += n; - } - } + str_shared_replace(str, rb_str_casemap(str, &flags, enc)); + modify = ONIGENC_CASE_MODIFIED & flags; } if (modify) return str; Index: ChangeLog =================================================================== --- ChangeLog (revision 55307) +++ ChangeLog (revision 55308) @@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Tue Jun 7 16:44:16 2016 Martin Duerst <duerst@i...> + + * string.c (rb_str_downcase_bang): Switch to use primitive except if + conversion can be done ASCII-only. + Tue Jun 7 16:13:36 2016 Martin Duerst <duerst@i...> * test/ruby/enc/test_case_comprehensive: Add regression tests for -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/