diff options
author | Eric Wong <e@80x24.org> | 2017-03-02 04:08:23 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2017-03-02 04:08:43 +0000 |
commit | f4c2ac4825f99ec4af529d65ae98abfaf034fb0f (patch) | |
tree | bbae58219dc4d158c033b892e0a7da67a969ecdc /lib/dtas/source/sox.rb | |
parent | c2e04a5715d4cfa2b42fa09ba1f641d3ce741685 (diff) | |
download | dtas-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/source/sox.rb')
-rw-r--r-- | lib/dtas/source/sox.rb | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/lib/dtas/source/sox.rb b/lib/dtas/source/sox.rb index 7f55c5d..f702b41 100644 --- a/lib/dtas/source/sox.rb +++ b/lib/dtas/source/sox.rb @@ -52,19 +52,16 @@ class DTAS::Source::Sox # :nodoc: if out =~ /\nComments\s*:[ \t]*\n?(.*)\z/mn comments = dst['comments'] = {} - # we use eval "#{str.inspect}".freeze - # take advantage of the VM-wide dedupe in MRI (rb_fstring): key = nil $1.split(/\n/n).each do |line| if line.sub!(/^([^=]+)=/ni, '') - key = $1.upcase - key = eval "#{key.inspect}.freeze" + key = DTAS.dedupe_str($1.upcase) end (comments[key] ||= ''.b) << "#{line}\n" unless line.empty? end comments.each do |k,v| v.chomp! - comments[k] = eval "#{v.inspect}.freeze" + comments[k] = DTAS.dedupe_str(v) end end dst |