From fc8e446d5da1887044c86ed07e8cf2eee6cf2cfd Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sun, 24 Jan 2016 09:41:09 +0000 Subject: String#split with a single-byte instead of regexp This reduces memory usage as a Regexp object is hundreds of bytes and a single-byte string object is only 40 bytes that is deduped within the VM. --- lib/dtas/player/client_handler.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/dtas/player/client_handler.rb') diff --git a/lib/dtas/player/client_handler.rb b/lib/dtas/player/client_handler.rb index 7ce9839..a6f5dba 100644 --- a/lib/dtas/player/client_handler.rb +++ b/lib/dtas/player/client_handler.rb @@ -422,7 +422,7 @@ module DTAS::Player::ClientHandler # :nodoc: def dpc_format(io, msg) new_fmt = @format.dup msg.each do |kv| - k, v = kv.split(/=/, 2) + k, v = kv.split('=', 2) case k when "type" new_fmt.valid_type?(v) or return io.emit("ERR invalid file type") @@ -497,7 +497,7 @@ module DTAS::Player::ClientHandler # :nodoc: before = src.to_state_hash.inspect sd = src.source_defaults msg.each do |kv| - k, v = kv.split(/=/, 2) + k, v = kv.split('=', 2) case k when "command" src.command = v.empty? ? sd[k] : v -- cgit v1.2.3-24-ge0c7