summaryrefslogtreecommitdiffstats
path: root/tool
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-09-08 09:16:45 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-09-08 09:16:45 +0000
commit04e539e84385f81afa5b34ad5a7d072e15e34a31 (patch)
tree478217aaa00be018731864a3e06694607ce8d17b /tool
parent622012a2aee85aba982213b69bef6caa303ea91a (diff)
downloadruby-04e539e84385f81afa5b34ad5a7d072e15e34a31.tar.gz
ruby-04e539e84385f81afa5b34ad5a7d072e15e34a31.tar.xz
ruby-04e539e84385f81afa5b34ad5a7d072e15e34a31.zip
* tool/transcode-tblgen.rb (ArrayCode): less string substitutions.
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@19242 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'tool')
-rw-r--r--tool/transcode-tblgen.rb23
1 files changed, 12 insertions, 11 deletions
diff --git a/tool/transcode-tblgen.rb b/tool/transcode-tblgen.rb
index 2eb4a0156..64d184c51 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