1
0
Fork 0
mirror of https://github.com/mperham/sidekiq.git synced 2022-11-09 13:52:34 -05:00

Reduce allocated objects

This commit is contained in:
fatkodima 2019-09-15 01:54:34 +03:00 committed by Mike Perham
parent de03df4160
commit 1d04192fe9
2 changed files with 4 additions and 2 deletions

View file

@ -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

View file

@ -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