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:
parent
de03df4160
commit
1d04192fe9
2 changed files with 4 additions and 2 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue