aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorMatthew Draper <matthew@trebex.net>2018-06-06 09:35:02 +0900
committerGitHub <noreply@github.com>2018-06-06 09:35:02 +0900
commitd0d3e964920602aa710507f6717010d852e37c86 (patch)
tree61497e74a4dd5f0ea70b4d46b456009026c9da44 /activerecord
parentc4c8e35cac419076a86112d7764f2afdef554483 (diff)
parenta46dcb7454b56c979cded85f2f4f875dcd2cfdf0 (diff)
downloadrails-d0d3e964920602aa710507f6717010d852e37c86.tar.gz
rails-d0d3e964920602aa710507f6717010d852e37c86.tar.bz2
rails-d0d3e964920602aa710507f6717010d852e37c86.zip
Merge pull request #33051 from SamSaffron/master
PERF: avoid allocating column names where possible
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/lib/active_record/attribute_methods.rb2
-rw-r--r--activerecord/lib/active_record/result.rb2
2 files changed, 2 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/attribute_methods.rb b/activerecord/lib/active_record/attribute_methods.rb
index 83b5a5e698..e4b8b1a330 100644
--- a/activerecord/lib/active_record/attribute_methods.rb
+++ b/activerecord/lib/active_record/attribute_methods.rb
@@ -26,7 +26,7 @@ module ActiveRecord
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
}
diff --git a/activerecord/lib/active_record/result.rb b/activerecord/lib/active_record/result.rb
index e54e8086dd..11626c8e31 100644
--- a/activerecord/lib/active_record/result.rb
+++ b/activerecord/lib/active_record/result.rb
@@ -125,7 +125,7 @@ module ActiveRecord
begin
# We freeze the strings to prevent them getting duped when
# used as keys in ActiveRecord::Base's @attributes hash
- columns = @columns.map { |c| c.dup.freeze }
+ columns = @columns.map(&:-@)
@rows.map { |row|
# In the past we used Hash[columns.zip(row)]
# though elegant, the verbose way is much more efficient