aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2012-10-15 11:11:43 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2012-10-15 11:11:43 -0700
commit02174a3efc6fa8f2e5e6f114e4cf0d8a06305b6a (patch)
tree380e954e2d63e3a0a0a4a0c7d5f0086d66e4b26d /activerecord/lib
parent046ab843b84db1935047dbc796f5acae66c45a42 (diff)
downloadrails-02174a3efc6fa8f2e5e6f114e4cf0d8a06305b6a.tar.gz
rails-02174a3efc6fa8f2e5e6f114e4cf0d8a06305b6a.tar.bz2
rails-02174a3efc6fa8f2e5e6f114e4cf0d8a06305b6a.zip
Move two hotspots to use Hash[] rather than Hash#dup
https://bugs.ruby-lang.org/issues/7166
Diffstat (limited to 'activerecord/lib')
-rw-r--r--activerecord/lib/active_record/relation.rb8
1 files changed, 5 insertions, 3 deletions
diff --git a/activerecord/lib/active_record/relation.rb b/activerecord/lib/active_record/relation.rb
index ed80422336..ecce7c703b 100644
--- a/activerecord/lib/active_record/relation.rb
+++ b/activerecord/lib/active_record/relation.rb
@@ -91,8 +91,10 @@ module ActiveRecord
end
def initialize_copy(other)
- @values = @values.dup
- @values[:bind] = @values[:bind].dup if @values[:bind]
+ # This method is a hot spot, so for now, use Hash[] to dup the hash.
+ # https://bugs.ruby-lang.org/issues/7166
+ @values = Hash[@values]
+ @values[:bind] = @values[:bind].dup if @values.key? :bind
reset
end
@@ -540,7 +542,7 @@ module ActiveRecord
end
def values
- @values.dup
+ Hash[@values]
end
def inspect