aboutsummaryrefslogtreecommitdiff
path: root/symtab.go
diff options
context:
space:
mode:
authorFumitoshi Ukai <fumitoshi.ukai@gmail.com>2015-04-30 10:20:18 +0900
committerFumitoshi Ukai <fumitoshi.ukai@gmail.com>2015-04-30 13:25:12 +0900
commit0b9e8132b64a22fb037313dcbecd8d84a9d3689a (patch)
tree7cc36fb73cbd63caaaeb4ff348cb69c267be8907 /symtab.go
parent89215d0641e70f9b0e31af0c7f52e181d4a0a20f (diff)
downloadkati-0b9e8132b64a22fb037313dcbecd8d84a9d3689a.tar.gz
rule_parser uses []byte
intern target names: share the same string as much as possible. $ ./repo/android.sh time kati -c -kati_memstats='alloc={{.Alloc}},total={{.TotalAlloc}},sys={{.Sys}},malloc={{.Mallocs}},free={{.Frees}},heap idle={{.HeapIdle}},inuse={{.HeapInuse}},released={{.HeapReleased}},pause={{.PauseTotalNs}},numGC={{.NumGC}}' ... alloc=686232544,total=9471977912,sys=990856408,malloc=204647708,free=200142535,heap idle=5914624,inuse=909885440,released=0,pause=10103883229,numGC=341
Diffstat (limited to 'symtab.go')
-rw-r--r--symtab.go20
1 files changed, 20 insertions, 0 deletions
diff --git a/symtab.go b/symtab.go
new file mode 100644
index 0000000..69b0b43
--- /dev/null
+++ b/symtab.go
@@ -0,0 +1,20 @@
+package main
+
+var symtab = make(map[string]string)
+
+func intern(s string) string {
+ if v, ok := symtab[s]; ok {
+ return v
+ }
+ symtab[s] = s
+ return s
+}
+
+func internBytes(s []byte) string {
+ if v, ok := symtab[string(s)]; ok {
+ return v
+ }
+ v := string(s)
+ symtab[v] = v
+ return v
+}