aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel/lib
diff options
context:
space:
mode:
authorSam <sam.saffron@gmail.com>2018-06-06 09:50:58 +1000
committerSam <sam.saffron@gmail.com>2018-06-06 09:50:58 +1000
commita46dcb7454b56c979cded85f2f4f875dcd2cfdf0 (patch)
tree7cb448f2d6764ecbfed081ab0263c6bbd726139b /activemodel/lib
parent32aa7cdd8f031dc756fdde3501efca7ff72bf576 (diff)
downloadrails-a46dcb7454b56c979cded85f2f4f875dcd2cfdf0.tar.gz
rails-a46dcb7454b56c979cded85f2f4f875dcd2cfdf0.tar.bz2
rails-a46dcb7454b56c979cded85f2f4f875dcd2cfdf0.zip
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.
Diffstat (limited to 'activemodel/lib')
-rw-r--r--activemodel/lib/active_model/attributes.rb2
1 files changed, 1 insertions, 1 deletions
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
}