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

ruby-changes:36257

From: duerst <ko1@a...>
Date: Sun, 9 Nov 2014 18:33:45 +0900 (JST)
Subject: [ruby-changes:36257] duerst:r48338 (trunk): lib/unicode_normalize/normalize.rb: Replaced if-else by case in self.normalized? in parallel to r48309.

duerst	2014-11-09 18:33:36 +0900 (Sun, 09 Nov 2014)

  New Revision: 48338

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

  Log:
    lib/unicode_normalize/normalize.rb: Replaced if-else by case in self.normalized? in parallel to r48309.

  Modified files:
    trunk/ChangeLog
    trunk/lib/unicode_normalize/normalize.rb
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 48337)
+++ ChangeLog	(revision 48338)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Sun Nov  9 18:33:33 2014  Martin Duerst <duerst@i...>
+
+	* lib/unicode_normalize/normalize.rb: Replaced if-else by
+	  case in self.normalized? in parallel to r48309.
+
 Sun Nov  9 18:07:00 2014  Tanaka Akira  <akr@f...>
 
 	* test/xmlrpc: Use assert_join_threads.
Index: lib/unicode_normalize/normalize.rb
===================================================================
--- lib/unicode_normalize/normalize.rb	(revision 48337)
+++ lib/unicode_normalize/normalize.rb	(revision 48338)
@@ -136,7 +136,8 @@ module UnicodeNormalize https://github.com/ruby/ruby/blob/trunk/lib/unicode_normalize/normalize.rb#L136
 
   def self.normalized?(string, form = :nfc)
     encoding = string.encoding
-    if encoding == Encoding::UTF_8
+    case encoding
+    when Encoding::UTF_8
       case form
       when :nfc then
         string.scan REGEXP_C do |match|
@@ -155,9 +156,9 @@ module UnicodeNormalize https://github.com/ruby/ruby/blob/trunk/lib/unicode_normalize/normalize.rb#L156
       else
         raise ArgumentError, "Invalid normalization form #{form}."
       end
-    elsif encoding == Encoding::US_ASCII
+    when Encoding::US_ASCII
       true
-    elsif  UNICODE_ENCODINGS.include? encoding
+    when **UNICODE_ENCODINGS
       normalized? string.encode(Encoding::UTF_8), form
     else
       raise Encoding::CompatibilityError, "Unicode Normalization not appropriate for #{encoding}"

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

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