Skip to content

Commit 0fc31fe

Browse files
authored
Merge pull request rails#42719 from jdelStrother/hash-optimization
Micro-optimize ActiveRecord::Core#hash
2 parents e9559f4 + 0c25a0b commit 0fc31fe

File tree

1 file changed

+2
-0
lines changed
  • activerecord/lib/active_record

1 file changed

+2
-0
lines changed

activerecord/lib/active_record/core.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -601,6 +601,8 @@ def ==(comparison_object)
601601
# Delegates to id in order to allow two records of the same type and id to work with something like:
602602
# [ Person.find(1), Person.find(2), Person.find(3) ] & [ Person.find(1), Person.find(4) ] # => [ Person.find(1) ]
603603
def hash
604+
id = self.id
605+
604606
if id
605607
self.class.hash ^ id.hash
606608
else

0 commit comments

Comments
 (0)