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

ruby-changes:35731

From: nobu <ko1@a...>
Date: Mon, 6 Oct 2014 12:08:26 +0900 (JST)
Subject: [ruby-changes:35731] nobu:r47813 (trunk): unicode_norm_gen.rb: optimize concatenation

nobu	2014-10-06 12:08:09 +0900 (Mon, 06 Oct 2014)

  New Revision: 47813

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

  Log:
    unicode_norm_gen.rb: optimize concatenation
    
    * tool/unicode_norm_gen.rb: optimization by string literal
      concatenation instead of runtime concatenation.

  Modified files:
    trunk/tool/unicode_norm_gen.rb
Index: tool/unicode_norm_gen.rb
===================================================================
--- tool/unicode_norm_gen.rb	(revision 47812)
+++ tool/unicode_norm_gen.rb	(revision 47813)
@@ -46,7 +46,7 @@ class Array https://github.com/ruby/ruby/blob/trunk/tool/unicode_norm_gen.rb#L46
       else
         first.to_UTF8 + '-' + last.to_UTF8
       end
-    end.line_slice "\" +\n    \""
+    end.line_slice "\" \\\n    \""
   end
 end
 
@@ -141,33 +141,42 @@ open("#{OuputDataDir}/normalize_tables.r https://github.com/ruby/ruby/blob/trunk/tool/unicode_norm_gen.rb#L141
 # automatically generated by tool/unicode_norm_gen.rb
 
 module Normalize
-  ACCENTS = "
-    [#{accent_array.to_regexp_chars}]
-  "
-  REGEXP_D_STRING = "  # composition starters and composition exclusions
-    [#{(composition_table.values+composition_exclusions).to_regexp_chars}]\#{ACCENTS}*
-    |  # characters that can be the result of a composition, except composition starters
-    [#{(composition_starters-composition_table.values).to_regexp_chars}]?\#{ACCENTS}+
-    |  # precomposed Hangul syllables
-    [\\u{AC00}-\\u{D7A4}]
-  "
-  REGEXP_C_STRING = "  # composition exclusions
-    [#{composition_exclusions.to_regexp_chars}]\#{ACCENTS}*
-    |  # composition starters and characters that can be the result of a composition
-    [#{(composition_starters+composition_table.values).to_regexp_chars}]?\#{ACCENTS}+
-    |  # Hangul syllables with separate trailer
-    [#{hangul_no_trailing.to_regexp_chars}][\\u11A8-\\u11C2]
-    |  # decomposed Hangul syllables
-    [\\u1100-\\u1112][\\u1161-\\u1175][\\u11A8-\\u11C2]?
-  "
-  REGEXP_K_STRING = "
-    [#{kompatible_table.keys.to_regexp_chars}]
-  "
+  accents = "" \\
+    "[#{accent_array.to_regexp_chars}]" \\
+  ""
+  ACCENTS = accents
+  REGEXP_D_STRING = "\#{''  # composition starters and composition exclusions
+    }" \\
+    "[#{(composition_table.values+composition_exclusions).to_regexp_chars}]\#{accents}*" \\
+    "|\#{''  # characters that can be the result of a composition, except composition starters
+    }" \\
+    "[#{(composition_starters-composition_table.values).to_regexp_chars}]?\#{accents}+" \\
+    "|\#{''  # precomposed Hangul syllables
+    }" \\
+    "[\\u{AC00}-\\u{D7A4}]" \\
+  ""
+  REGEXP_C_STRING = "\#{''  # composition exclusions
+    }" \\
+    "[#{composition_exclusions.to_regexp_chars}]\#{accents}*" \\
+    "|\#{''  # composition starters and characters that can be the result of a composition
+    }" \\
+    "[#{(composition_starters+composition_table.values).to_regexp_chars}]?\#{accents}+" \\
+    "|\#{''  # Hangul syllables with separate trailer
+    }" \\
+    "[#{hangul_no_trailing.to_regexp_chars}][\\u11A8-\\u11C2]" \\
+    "|\#{''  # decomposed Hangul syllables
+    }" \\
+    "[\\u1100-\\u1112][\\u1161-\\u1175][\\u11A8-\\u11C2]?" \\
+  ""
+  REGEXP_K_STRING = "" \\
+    "[#{kompatible_table.keys.to_regexp_chars}]" \\
+  ""
 
-  CLASS_TABLE = {
+  class_table = {
     #{class_table_str}
   }
-  CLASS_TABLE.default = 0
+  class_table.default = 0
+  CLASS_TABLE = class_table
 
   DECOMPOSITION_TABLE = {
     #{decomposition_table.to_hash_string}

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

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