summaryrefslogtreecommitdiff
path: root/tool/transcode-tblgen.rb
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-09-07 09:30:54 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-09-07 09:30:54 +0000
commitdcdc7579c5e9bf5596e19f52e30d1f2bcd67610b (patch)
treec44230d165f42dce6149e8a2343372e42e49239e /tool/transcode-tblgen.rb
parentc0bec2fae1d6adf77c853457942217e89ea85bcf (diff)
* tool/transcode-tblgen.rb (ActionMap#generate_info): use a memo to
avoid duplication for STR1. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19215 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'tool/transcode-tblgen.rb')
-rw-r--r--tool/transcode-tblgen.rb22
1 files changed, 15 insertions, 7 deletions
diff --git a/tool/transcode-tblgen.rb b/tool/transcode-tblgen.rb
index 95031c4..33368db 100644
--- a/tool/transcode-tblgen.rb
+++ b/tool/transcode-tblgen.rb
@@ -277,6 +277,8 @@ class ActionMap
code
end
+ StrMemo = {}
+
def generate_info(info)
case info
when :nomap
@@ -302,13 +304,19 @@ class ActionMap
when /\A(f[0-7])([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])\z/i
"o4(0x#$1,0x#$2,0x#$3,0x#$4)"
when /\A([0-9a-f][0-9a-f]){0,255}\z/i
- bytes = info
- len = info.length/2
- size = @bytes_code.length
- @bytes_code.insert_at_last(1 + len,
- "\#define str1_#{size} makeSTR1(#{size})\n" +
- " #{len}," + info.gsub(/../, ' 0x\&,') + "\n")
- "str1_#{size}"
+ bytes = info.upcase
+ if n = StrMemo[bytes]
+ n
+ else
+ len = info.length/2
+ size = @bytes_code.length
+ @bytes_code.insert_at_last(1 + len,
+ "\#define str1_#{size} makeSTR1(#{size})\n" +
+ " #{len}," + info.gsub(/../, ' 0x\&,') + "\n")
+ n = "str1_#{size}"
+ StrMemo[bytes] = n
+ n
+ end
when /\A\/\*BYTE_LOOKUP\*\// # pointer to BYTE_LOOKUP structure
$'.to_s
else