From 1625494febb1039346613868f826d1263acc795d Mon Sep 17 00:00:00 2001 From: akr Date: Mon, 8 Sep 2008 09:16:45 +0000 Subject: * tool/transcode-tblgen.rb (ArrayCode): less string substitutions. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19242 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- tool/transcode-tblgen.rb | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) (limited to 'tool') diff --git a/tool/transcode-tblgen.rb b/tool/transcode-tblgen.rb index 2eb4a01565..64d184c512 100644 --- a/tool/transcode-tblgen.rb +++ b/tool/transcode-tblgen.rb @@ -157,27 +157,28 @@ end class ArrayCode def initialize(type, name) - @code = <<"End" -static const #{type} -#{name}[0] = { -}; -End + @type = type + @name = name + @len = 0; + @content = '' end def length - @code[/\[\d+\]/][1...-1].to_i + @len end def insert_at_last(num, str) newnum = self.length + num - @code.sub!(/^(\};\n\z)/) { - str + $1 - } - @code.sub!(/\[\d+\]/) { "[#{newnum}]" } + @content << str + @len += num end def to_s - @code.dup + <<"End" +static const #{@type} +#{@name}[#{@len}] = { +#{@content}}; +End end end -- cgit v1.2.3