mirror of https://github.com/rails/rails
Remove hash allocation in Store#namespace_key
Previously, every call to `namespace_key` would merge the options given with the Store's default options. This unnecessarily allocates a new hash when all `namespace_key` needs is the `namespace` option. This commit removes the allocation by simply checking the default options after checking that the passed options do not contain a `namespace` key.
This commit is contained in:
parent
34ea0a5dd2
commit
b87e1e6163
|
@ -945,9 +945,12 @@ module ActiveSupport
|
|||
#
|
||||
# namespace_key 'foo', namespace: -> { 'cache' }
|
||||
# # => 'cache:foo'
|
||||
def namespace_key(key, options = nil)
|
||||
options = merged_options(options)
|
||||
namespace = options[:namespace]
|
||||
def namespace_key(key, call_options = nil)
|
||||
namespace = if call_options&.key?(:namespace)
|
||||
call_options[:namespace]
|
||||
else
|
||||
options[:namespace]
|
||||
end
|
||||
|
||||
if namespace.respond_to?(:call)
|
||||
namespace = namespace.call
|
||||
|
|
Loading…
Reference in New Issue