ruby-changes:15066
From: akr <ko1@a...>
Date: Mon, 15 Mar 2010 22:00:16 +0900 (JST)
Subject: [ruby-changes:15066] Ruby:r26942 (trunk): * tool/transcode-tblgen.rb: ActionMap#each_firstbyte inlined.
akr 2010-03-15 21:59:54 +0900 (Mon, 15 Mar 2010) New Revision: 26942 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=26942 Log: * tool/transcode-tblgen.rb: ActionMap#each_firstbyte inlined. Modified files: trunk/ChangeLog trunk/tool/transcode-tblgen.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 26941) +++ ChangeLog (revision 26942) @@ -1,3 +1,7 @@ +Mon Mar 15 21:58:03 2010 Tanaka Akira <akr@f...> + + * tool/transcode-tblgen.rb: ActionMap#each_firstbyte inlined. + Mon Mar 15 21:22:49 2010 Tanaka Akira <akr@f...> * tool/transcode-tblgen.rb (transcode_tblgen): add valid_encoding Index: tool/transcode-tblgen.rb =================================================================== --- tool/transcode-tblgen.rb (revision 26941) +++ tool/transcode-tblgen.rb (revision 26942) @@ -308,16 +308,6 @@ end end - def each_firstbyte - @tree.each {|byte_min, byte_max, child_tree| - byte_min.upto(byte_max) {|byte| - prefix = @prefix + ("%02X" % byte) - am = ActionMap.new(prefix, child_tree) - yield byte, am - } - } - end - OffsetsMemo = {} InfosMemo = {} @@ -486,13 +476,22 @@ end table = Array.new(0x100, :invalid) - each_firstbyte {|byte, rest| + @tree.each {|byte_min, byte_max, child_tree| + prefix = @prefix + (byte_min == byte_max ? "%02X" % byte_min : "{%02X-%02X}" % [byte_min, byte_max]) + rest = ActionMap.new(prefix, child_tree) if a = rest.empty_action - table[byte] = a + byte_min.upto(byte_max) {|byte| + table[byte] = a + } else name_hint2 = nil - name_hint2 = "#{name_hint}_#{'%02X' % byte}" if name_hint - table[byte] = "/*BYTE_LOOKUP*/" + rest.gennode(bytes_code, words_code, name_hint2) + if name_hint + name_hint2 = "#{name_hint}_#{'%02X' % byte_min}" + end + v = "/*BYTE_LOOKUP*/" + rest.gennode(bytes_code, words_code, name_hint2) + byte_min.upto(byte_max) {|byte| + table[byte] = v + } end } -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/