aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorJon Moss <me@jonathanmoss.me>2016-08-27 19:06:04 -0400
committerJon Moss <me@jonathanmoss.me>2016-08-27 19:06:04 -0400
commit79a2d07851be86d769a1929d22caea9f46badbb1 (patch)
tree966062710ee1addade3b102d49fea71d2080f6ab /activerecord
parenta63de6db433dffb610509a65aed02991aa718c32 (diff)
downloadrails-79a2d07851be86d769a1929d22caea9f46badbb1.tar.gz
rails-79a2d07851be86d769a1929d22caea9f46badbb1.tar.bz2
rails-79a2d07851be86d769a1929d22caea9f46badbb1.zip
Switch back to `Hash.dup`
The performance difference between `Hash[]` and `Hash.dup` looks to have been narrowed by @tenderlove via this commit --> https://github.com/ruby/ruby/commit/b3803cc49ad382e23291d75ce57ffb2b74bb9577#diff-eff9999082c8ce7d8ba1fc1d79f439cf. Since this commit first appeared in Ruby 2.0.0, and since Rails now requires a minimum Ruby version of 2.2.2, this performance boost should be available for all users. Relevant links: - This behavior was originally added via https://github.com/rails/rails/commit/02174a3efc6fa8f2e5e6f114e4cf0d8a06305b6a - The conversation on the Ruby issue tracker lives here --> https://bugs.ruby-lang.org/issues/7166
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/lib/active_record/relation.rb6
1 files changed, 2 insertions, 4 deletions
diff --git a/activerecord/lib/active_record/relation.rb b/activerecord/lib/active_record/relation.rb
index 85b1ddf8db..d7de1032b6 100644
--- a/activerecord/lib/active_record/relation.rb
+++ b/activerecord/lib/active_record/relation.rb
@@ -29,9 +29,7 @@ module ActiveRecord
end
def initialize_copy(other)
- # 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 = @values.dup
reset
end
@@ -661,7 +659,7 @@ module ActiveRecord
end
def values
- Hash[@values]
+ @values.dup
end
def inspect