unicode_norm_gen.rb: optimize concatenation

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

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47813 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2014-10-06 03:08:09 +00:00
parent daea1a5f3a
commit 240b12c6fc

View File

@ -46,7 +46,7 @@ class Array
else else
first.to_UTF8 + '-' + last.to_UTF8 first.to_UTF8 + '-' + last.to_UTF8
end end
end.line_slice "\" +\n \"" end.line_slice "\" \\\n \""
end end
end end
@ -141,33 +141,42 @@ open("#{OuputDataDir}/normalize_tables.rb", "w").print <<MAPPING_TABLE_FILE_END
# automatically generated by tool/unicode_norm_gen.rb # automatically generated by tool/unicode_norm_gen.rb
module Normalize module Normalize
ACCENTS = " accents = "" \\
[#{accent_array.to_regexp_chars}] "[#{accent_array.to_regexp_chars}]" \\
" ""
REGEXP_D_STRING = " # composition starters and composition exclusions ACCENTS = accents
[#{(composition_table.values+composition_exclusions).to_regexp_chars}]\#{ACCENTS}* REGEXP_D_STRING = "\#{'' # composition starters and composition exclusions
| # characters that can be the result of a composition, except composition starters }" \\
[#{(composition_starters-composition_table.values).to_regexp_chars}]?\#{ACCENTS}+ "[#{(composition_table.values+composition_exclusions).to_regexp_chars}]\#{accents}*" \\
| # precomposed Hangul syllables "|\#{'' # characters that can be the result of a composition, except composition starters
[\\u{AC00}-\\u{D7A4}] }" \\
" "[#{(composition_starters-composition_table.values).to_regexp_chars}]?\#{accents}+" \\
REGEXP_C_STRING = " # composition exclusions "|\#{'' # precomposed Hangul syllables
[#{composition_exclusions.to_regexp_chars}]\#{ACCENTS}* }" \\
| # composition starters and characters that can be the result of a composition "[\\u{AC00}-\\u{D7A4}]" \\
[#{(composition_starters+composition_table.values).to_regexp_chars}]?\#{ACCENTS}+ ""
| # Hangul syllables with separate trailer REGEXP_C_STRING = "\#{'' # composition exclusions
[#{hangul_no_trailing.to_regexp_chars}][\\u11A8-\\u11C2] }" \\
| # decomposed Hangul syllables "[#{composition_exclusions.to_regexp_chars}]\#{accents}*" \\
[\\u1100-\\u1112][\\u1161-\\u1175][\\u11A8-\\u11C2]? "|\#{'' # composition starters and characters that can be the result of a composition
" }" \\
REGEXP_K_STRING = " "[#{(composition_starters+composition_table.values).to_regexp_chars}]?\#{accents}+" \\
[#{kompatible_table.keys.to_regexp_chars}] "|\#{'' # 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_str}
} }
CLASS_TABLE.default = 0 class_table.default = 0
CLASS_TABLE = class_table
DECOMPOSITION_TABLE = { DECOMPOSITION_TABLE = {
#{decomposition_table.to_hash_string} #{decomposition_table.to_hash_string}