From 1d04192fe9db2eec5c521fcdea768a3676535087 Mon Sep 17 00:00:00 2001 From: fatkodima Date: Sun, 15 Sep 2019 01:54:34 +0300 Subject: [PATCH] Reduce allocated objects --- lib/sidekiq/logger.rb | 2 +- lib/sidekiq/processor.rb | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/sidekiq/logger.rb b/lib/sidekiq/logger.rb index 7475372d..61c58162 100644 --- a/lib/sidekiq/logger.rb +++ b/lib/sidekiq/logger.rb @@ -9,7 +9,7 @@ module Sidekiq ctx.merge!(hash) yield ensure - hash.keys.each { |key| ctx.delete(key) } + hash.each_key { |key| ctx.delete(key) } end def ctx diff --git a/lib/sidekiq/processor.rb b/lib/sidekiq/processor.rb index 76d5225d..519c9f16 100644 --- a/lib/sidekiq/processor.rb +++ b/lib/sidekiq/processor.rb @@ -269,13 +269,15 @@ module Sidekiq end def constantize(str) + return Object.const_get(str) unless str.include?("::") + names = str.split("::") names.shift if names.empty? || names.first.empty? names.inject(Object) do |constant, name| # the false flag limits search for name to under the constant namespace # which mimics Rails' behaviour - constant.const_defined?(name, false) ? constant.const_get(name, false) : constant.const_missing(name) + constant.const_get(name, false) end end end