Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Move two hotspots to use Hash[] rather than Hash#dup

  • Loading branch information...
commit 02174a3efc6fa8f2e5e6f114e4cf0d8a06305b6a 1 parent 046ab84
@tenderlove tenderlove authored
Showing with 5 additions and 3 deletions.
  1. +5 −3 activerecord/lib/active_record/relation.rb
View
8 activerecord/lib/active_record/relation.rb
@@ -91,8 +91,10 @@ def new(*args, &block)
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 @@ def blank?
end
def values
- @values.dup
+ Hash[@values]
end
def inspect
Please sign in to comment.
Something went wrong with that request. Please try again.