Skip to content

Commit 74fceba

Browse files
authored
Merge pull request rails#53274 from jhawthorn/faster_hash
Avoid reading id twice in AR::Core#hash
2 parents b943622 + aeac4fc commit 74fceba

File tree

1 file changed

+1
-1
lines changed
  • activerecord/lib/active_record

1 file changed

+1
-1
lines changed

activerecord/lib/active_record/core.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -618,7 +618,7 @@ def ==(comparison_object)
618618
def hash
619619
id = self.id
620620

621-
if primary_key_values_present?
621+
if self.class.composite_primary_key? ? primary_key_values_present? : id
622622
self.class.hash ^ id.hash
623623
else
624624
super

0 commit comments

Comments
 (0)