about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2022-01-11 18:21:04 +0000
committerEric Wong <e@80x24.org>2022-01-21 20:29:57 +0000
commitbf9787ac517fe19af5fd6ba918a66b220fcbc923 (patch)
treee30cf4a74c599bb8037f41340fc1ed8800d8af4c
parent88a8d4793473259b392241f1e2d20d39bd96b214 (diff)
downloaddtas-bf9787ac517fe19af5fd6ba918a66b220fcbc923.tar.gz
This ought to save some memory for dtas-player and
dtas-readahead users with multiple instances of the same
track(s) on their track list.
-rwxr-xr-xbin/dtas-readahead7
-rw-r--r--lib/dtas/edit_client.rb4
-rw-r--r--lib/dtas/mcache.rb4
-rw-r--r--lib/dtas/player.rb6
-rw-r--r--lib/dtas/sigevent/fiddle_efd.rb4
-rw-r--r--lib/dtas/source/sox.rb2
-rw-r--r--lib/dtas/track.rb2
7 files changed, 14 insertions, 15 deletions
diff --git a/bin/dtas-readahead b/bin/dtas-readahead
index 3f46b95..996142c 100755
--- a/bin/dtas-readahead
+++ b/bin/dtas-readahead
@@ -141,7 +141,7 @@ def do_open(path)
         buf << fp.read(fp.size - 4)
         Dir.chdir(File.dirname(path)) do
           yml = DTAS.yaml_load(buf)
-          x = yml['infile'] and return File.open(File.expand_path(x).freeze)
+          x = yml['infile'] and return File.open(-File.expand_path(x))
         end
       end
     end
@@ -158,9 +158,8 @@ begin
   cur = DTAS.yaml_load(c.req('current'))
   while @todo_ra > 0 && fp.nil?
     if current = cur['current']
-      track = current['infile']
+      track = -current['infile']
       break unless track.kind_of?(String)
-      track.freeze
       fp = work[track] ||= do_open(track)
       cur_pid = current['pid']
       if fp
@@ -197,7 +196,7 @@ begin
     repeat = c.req('tl repeat').split[-1]
     while @todo_ra > 0 && idx && (cid = ids[idx])
       fp = nil
-      track = c.req("tl get #{cid}").sub!(/\A1 \d+=/, '').freeze
+      track = -(c.req("tl get #{cid}").sub!(/\A1 \d+=/, ''))
       begin
         fp = work[track] ||= do_open(track)
       rescue SystemCallError
diff --git a/lib/dtas/edit_client.rb b/lib/dtas/edit_client.rb
index a885060..036d036 100644
--- a/lib/dtas/edit_client.rb
+++ b/lib/dtas/edit_client.rb
@@ -1,4 +1,4 @@
-# Copyright (C) 2013-2020 all contributors <dtas-all@nongnu.org>
+# Copyright (C) all contributors <dtas-all@nongnu.org>
 # License: GPL-3.0+ <https://www.gnu.org/licenses/gpl-3.0.txt>
 # frozen_string_literal: true
 require 'tempfile'
@@ -14,7 +14,7 @@ module DTAS::EditClient # :nodoc:
       v.empty? and next
       return v
     end
-    'vi'.freeze
+    'vi'
   end
 
   def client_socket
diff --git a/lib/dtas/mcache.rb b/lib/dtas/mcache.rb
index 817bfb8..4f1e9e8 100644
--- a/lib/dtas/mcache.rb
+++ b/lib/dtas/mcache.rb
@@ -1,4 +1,4 @@
-# Copyright (C) 2016-2020 all contributors <dtas-all@nongnu.org>
+# Copyright (C) all contributors <dtas-all@nongnu.org>
 # License: GPL-3.0+ <https://www.gnu.org/licenses/gpl-3.0.txt>
 # frozen_string_literal: true
 # encoding: binary
@@ -22,7 +22,7 @@ class DTAS::Mcache
     @tbl[bucket] = begin
       cur = cur ? cur.clear : {}
       if ret = yield(infile, cur)
-        ret[:infile] = infile.frozen? ? infile : infile.dup.freeze
+        ret[:infile] = infile.frozen? ? infile : -(infile.dup)
         ret[:btime] = DTAS.now
       end
       ret
diff --git a/lib/dtas/player.rb b/lib/dtas/player.rb
index ff7440f..243f0b0 100644
--- a/lib/dtas/player.rb
+++ b/lib/dtas/player.rb
@@ -208,13 +208,13 @@ class DTAS::Player # :nodoc:
     command = msg.shift
     case command
     when "enq"
-      enq_handler(io, msg[0])
+      enq_handler(io, -msg[0])
     when "enq-cmd"
-      enq_handler(io, { "command" => msg[0]})
+      enq_handler(io, { "command" => -msg[0]})
     when "pause", "play", "play_pause"
       play_pause_handler(io, command)
     when "pwd"
-      io.emit(Dir.pwd)
+      io.emit(-Dir.pwd)
     else
       m = "dpc_#{command.tr('-', '_')}"
       __send__(m, io, msg) if respond_to?(m)
diff --git a/lib/dtas/sigevent/fiddle_efd.rb b/lib/dtas/sigevent/fiddle_efd.rb
index 40cec77..ec9ec65 100644
--- a/lib/dtas/sigevent/fiddle_efd.rb
+++ b/lib/dtas/sigevent/fiddle_efd.rb
@@ -1,4 +1,4 @@
-# Copyright (C) 2013-2020 all contributors <dtas-all@nongnu.org>
+# Copyright (C) all contributors <dtas-all@nongnu.org>
 # License: GPL-3.0+ <https://www.gnu.org/licenses/gpl-3.0.txt>
 # frozen_string_literal: true
 
@@ -13,7 +13,7 @@ class DTAS::Sigevent # :nodoc:
     Fiddle::TYPE_INT) # fd
 
   attr_reader :to_io
-  ONE = [ 1 ].pack('Q').freeze
+  ONE = -([ 1 ].pack('Q'))
 
   def initialize
     fd = EventFD.call(0, 02000000|00004000) # EFD_CLOEXEC|EFD_NONBLOCK
diff --git a/lib/dtas/source/sox.rb b/lib/dtas/source/sox.rb
index e38e23c..6ca29bc 100644
--- a/lib/dtas/source/sox.rb
+++ b/lib/dtas/source/sox.rb
@@ -63,7 +63,7 @@ class DTAS::Source::Sox # :nodoc:
         comments.each do |k,v|
           v.chomp!
           DTAS.try_enc(v, enc)
-          comments[k] = v
+          comments[k] = -v
         end
       end
       dst
diff --git a/lib/dtas/track.rb b/lib/dtas/track.rb
index 85b667a..3f4b813 100644
--- a/lib/dtas/track.rb
+++ b/lib/dtas/track.rb
@@ -9,6 +9,6 @@ class DTAS::Track # :nodoc:
 
   def initialize(track_id, path)
     @track_id = track_id
-    @to_path = path
+    @to_path = -path
   end
 end