1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

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
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.rb", "w").print <<MAPPING_TABLE_FILE_END
# 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}