From a46dcb7454b56c979cded85f2f4f875dcd2cfdf0 Mon Sep 17 00:00:00 2001 From: Sam Date: Wed, 6 Jun 2018 09:50:58 +1000 Subject: PERF: avoid allocating column names where possible When requesting columns names from database adapters AR:Result would dup/freeze column names, this prefers using fstrings which cuts down on repeat allocations Attributes that are retained keep these fstrings around for the long term Note, this has the highest impact on "short" result sets, eg: Topic.first where you can void allocating the number of columns * String. --- activemodel/lib/active_model/attributes.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'activemodel/lib') diff --git a/activemodel/lib/active_model/attributes.rb b/activemodel/lib/active_model/attributes.rb index 7d44f7f2a3..5bf213d593 100644 --- a/activemodel/lib/active_model/attributes.rb +++ b/activemodel/lib/active_model/attributes.rb @@ -103,7 +103,7 @@ module ActiveModel def self.set_name_cache(name, value) const_name = "ATTR_#{name}" unless const_defined? const_name - const_set const_name, value.dup.freeze + const_set const_name, -value end end } -- cgit v1.2.3