* tool/transcode-tblgen.rb: redundant loop removed.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26946 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
akr 2010-03-15 22:21:24 +00:00
parent 32ea96f682
commit 34533445c8
2 changed files with 9 additions and 12 deletions

View File

@ -1,3 +1,7 @@
Tue Mar 16 07:16:56 2010 Tanaka Akira <akr@fsij.org>
* tool/transcode-tblgen.rb: redundant loop removed.
Tue Mar 16 07:01:43 2010 Tanaka Akira <akr@fsij.org> Tue Mar 16 07:01:43 2010 Tanaka Akira <akr@fsij.org>
* tool/transcode-tblgen.rb: refactored to use tree as memo key. * tool/transcode-tblgen.rb: refactored to use tree as memo key.

View File

@ -101,17 +101,11 @@ class Branch
end end
class ActionMap class ActionMap
def self.parse_to_rects(hash) def self.parse_to_rects(mapping)
h = {}
hash.each {|pat, action|
pat = pat.to_s
h[pat] = action
}
hash = h
rects = [] rects = []
n = 0 n = 0
hash.each {|pat, action| mapping.each {|pat, action|
pat = pat.to_s
if /\A\s*\(empset\)\s*\z/ =~ pat if /\A\s*\(empset\)\s*\z/ =~ pat
next next
elsif /\A\s*\(empstr\)\s*\z/ =~ pat elsif /\A\s*\(empstr\)\s*\z/ =~ pat
@ -189,8 +183,8 @@ class ActionMap
} }
end end
def self.parse(hash) def self.parse(mapping)
rects = parse_to_rects(hash) rects = parse_to_rects(mapping)
tree = build_tree(rects) tree = build_tree(rects)
self.new(tree) self.new(tree)
end end
@ -925,4 +919,3 @@ if __FILE__ == $0
print result print result
end end
end end