summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--tool/transcode-tblgen.rb22
2 files changed, 20 insertions, 7 deletions
diff --git a/ChangeLog b/ChangeLog
index 4654478f90d..4142b1feeaf 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Sun Sep 7 18:28:05 2008 Tanaka Akira <akr@fsij.org>
+
+ * tool/transcode-tblgen.rb (ActionMap#generate_info): use a memo to
+ avoid duplication for STR1.
+
Sun Sep 7 18:10:28 2008 Tanaka Akira <akr@fsij.org>
* transcode_data.h (STR1): defined for a string up to 255 bytes.
diff --git a/tool/transcode-tblgen.rb b/tool/transcode-tblgen.rb
index 95031c43a01..33368db2e9d 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