mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
activesupport: Memoize name object allocation in CurrentAttributes.instance
Also, use a symbol key for a faster hash lookup.
This commit is contained in:
parent
6b40767df8
commit
65cd16b541
1 changed files with 5 additions and 1 deletions
|
@ -91,7 +91,7 @@ module ActiveSupport
|
|||
class << self
|
||||
# Returns singleton instance for this class in this thread. If none exists, one is created.
|
||||
def instance
|
||||
current_instances[name] ||= new
|
||||
current_instances[current_instances_key] ||= new
|
||||
end
|
||||
|
||||
# Declares one or more attributes that will be given both class and instance accessor methods.
|
||||
|
@ -150,6 +150,10 @@ module ActiveSupport
|
|||
Thread.current[:current_attributes_instances] ||= {}
|
||||
end
|
||||
|
||||
def current_instances_key
|
||||
@current_instances_key ||= name.to_sym
|
||||
end
|
||||
|
||||
def method_missing(name, *args, &block)
|
||||
# Caches the method definition as a singleton method of the receiver.
|
||||
#
|
||||
|
|
Loading…
Reference in a new issue