about summary refs log tree commit homepage
path: root/lib/dtas/mlib.rb
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2017-03-02 04:08:23 +0000
committerEric Wong <e@80x24.org>2017-03-02 04:08:43 +0000
commitf4c2ac4825f99ec4af529d65ae98abfaf034fb0f (patch)
treebbae58219dc4d158c033b892e0a7da67a969ecdc /lib/dtas/mlib.rb
parentc2e04a5715d4cfa2b42fa09ba1f641d3ce741685 (diff)
downloaddtas-f4c2ac4825f99ec4af529d65ae98abfaf034fb0f.tar.gz
This is faster than relying on eval() for older Rubies.
https://bugs.ruby-lang.org/issues/13077
Ruby 2.5 is targetted for release in December 2017.
Diffstat (limited to 'lib/dtas/mlib.rb')
-rw-r--r--lib/dtas/mlib.rb10
1 files changed, 6 insertions, 4 deletions
diff --git a/lib/dtas/mlib.rb b/lib/dtas/mlib.rb
index dbd46da..0945153 100644
--- a/lib/dtas/mlib.rb
+++ b/lib/dtas/mlib.rb
@@ -190,7 +190,9 @@ class DTAS::Mlib # :nodoc:
       tag_id = tag_map[x] and tag_map["#{x}number"] = tag_id
     end
     @tag_rmap = tag_map.invert.freeze
-    tag_map.merge!(Hash[*(tag_map.map { |k,v| [k.upcase.freeze, v] }.flatten!)])
+    tag_map.merge!(Hash[*(tag_map.map { |k,v|
+      [DTAS.dedupe_str(k.upcase), v]
+    }.flatten!)])
     @tag_map = tag_map.freeze
   end
 
@@ -400,7 +402,7 @@ class DTAS::Mlib # :nodoc:
     return '/' if base == '' # root_node
     parent_id = node[:parent_id]
     base += '/' unless node[:tlen] >= 0
-    ppath = cache[parent_id] and return "#{ppath}/#{base}"
+    ppath = cache[parent_id] and return DTAS.dedupe_str("#{ppath}/#{base}")
     parts = []
     begin
       node = @db[:nodes][id: node[:parent_id]]
@@ -408,9 +410,9 @@ class DTAS::Mlib # :nodoc:
       parts.unshift node[:name]
     end while true
     parts.unshift('')
-    cache[parent_id] = parts.join('/')
+    cache[parent_id] = DTAS.dedupe_str(parts.join('/'))
     parts << base
-    parts.join('/').freeze
+    DTAS.dedupe_str(parts.join('/'))
   end
 
   def emit_recurse(node, cache, cb)