From 02174a3efc6fa8f2e5e6f114e4cf0d8a06305b6a Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Mon, 15 Oct 2012 11:11:43 -0700 Subject: Move two hotspots to use Hash[] rather than Hash#dup https://bugs.ruby-lang.org/issues/7166 --- activerecord/lib/active_record/relation.rb | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'activerecord/lib') 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 -- cgit v1.2.3