зеркало из https://github.com/github/ruby.git
* string.c (rb_str_downcase_bang): Switch to use primitive except if
conversion can be done ASCII-only. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55308 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
1b98612090
Коммит
53a3e3ddd9
|
@ -1,3 +1,8 @@
|
||||||
|
Tue Jun 7 16:44:16 2016 Martin Duerst <duerst@it.aoyama.ac.jp>
|
||||||
|
|
||||||
|
* 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@it.aoyama.ac.jp>
|
Tue Jun 7 16:13:36 2016 Martin Duerst <duerst@it.aoyama.ac.jp>
|
||||||
|
|
||||||
* test/ruby/enc/test_case_comprehensive: Add regression tests for
|
* test/ruby/enc/test_case_comprehensive: Add regression tests for
|
||||||
|
|
31
string.c
31
string.c
|
@ -5948,11 +5948,7 @@ rb_str_downcase_bang(int argc, VALUE *argv, VALUE str)
|
||||||
enc = STR_ENC_GET(str);
|
enc = STR_ENC_GET(str);
|
||||||
rb_str_check_dummy_enc(enc);
|
rb_str_check_dummy_enc(enc);
|
||||||
s = RSTRING_PTR(str); send = RSTRING_END(str);
|
s = RSTRING_PTR(str); send = RSTRING_END(str);
|
||||||
if (rb_enc_unicode_p(enc)) {
|
if (!(flags&ONIGENC_CASE_FOLD_TURKISH_AZERI) && ENC_CODERANGE(str)==ENC_CODERANGE_7BIT) {
|
||||||
str_shared_replace(str, rb_str_casemap(str, &flags, enc));
|
|
||||||
modify = ONIGENC_CASE_MODIFIED & flags;
|
|
||||||
}
|
|
||||||
else if (single_byte_optimizable(str)) {
|
|
||||||
while (s < send) {
|
while (s < send) {
|
||||||
unsigned int c = *(unsigned char*)s;
|
unsigned int c = *(unsigned char*)s;
|
||||||
|
|
||||||
|
@ -5964,29 +5960,8 @@ rb_str_downcase_bang(int argc, VALUE *argv, VALUE str)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int ascompat = rb_enc_asciicompat(enc);
|
str_shared_replace(str, rb_str_casemap(str, &flags, enc));
|
||||||
|
modify = ONIGENC_CASE_MODIFIED & flags;
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (modify) return str;
|
if (modify) return str;
|
||||||
|
|
Загрузка…
Ссылка в новой задаче