[前][次][番号順一覧][スレッド一覧]

ruby-changes:43256

From: duerst <ko1@a...>
Date: Wed, 8 Jun 2016 21:57:49 +0900 (JST)
Subject: [ruby-changes:43256] duerst:r55330 (trunk): * string.c: Special-case :ascii option in rb_str_upcase_bang.

duerst	2016-06-08 21:57:44 +0900 (Wed, 08 Jun 2016)

  New Revision: 55330

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=55330

  Log:
    * string.c: Special-case :ascii option in rb_str_upcase_bang.

  Modified files:
    trunk/ChangeLog
    trunk/string.c
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 55329)
+++ ChangeLog	(revision 55330)
@@ -1,3 +1,7 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Wed Jun  8 21:57:41 2016  Martin Duerst  <duerst@i...>
+
+	* string.c: Special-case :ascii option in rb_str_upcase_bang.
+
 Wed Jun  8 21:28:36 2016  Martin Duerst  <duerst@i...>
 
 	* string.c: New static function rb_str_ascii_casemap; special-casing
Index: string.c
===================================================================
--- string.c	(revision 55329)
+++ string.c	(revision 55330)
@@ -5871,7 +5871,6 @@ static VALUE https://github.com/ruby/ruby/blob/trunk/string.c#L5871
 rb_str_upcase_bang(int argc, VALUE *argv, VALUE str)
 {
     rb_encoding *enc;
-    int modify = 0;
     OnigCaseFoldType flags = ONIGENC_CASE_UPCASE;
 
     flags = check_case_options(argc, argv, flags);
@@ -5887,17 +5886,17 @@ rb_str_upcase_bang(int argc, VALUE *argv https://github.com/ruby/ruby/blob/trunk/string.c#L5886
 
 	    if (rb_enc_isascii(c, enc) && 'a' <= c && c <= 'z') {
 		*s = 'A' + (c - 'a');
-		modify = 1;
+		flags |= ONIGENC_CASE_MODIFIED;
 	    }
 	    s++;
 	}
     }
-    else {
+    else if (flags&ONIGENC_CASE_ASCII_ONLY)
+        rb_str_ascii_casemap(str, &flags, enc);
+    else
 	str_shared_replace(str, rb_str_casemap(str, &flags, enc));
-	modify = ONIGENC_CASE_MODIFIED & flags;
-    }
 
-    if (modify) return str;
+    if (ONIGENC_CASE_MODIFIED&flags) return str;
     return Qnil;
 }
 

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]