Skip to content

Commit

Permalink
Merge pull request rails#53274 from jhawthorn/faster_hash
Browse files Browse the repository at this point in the history
Avoid reading id twice in AR::Core#hash
  • Loading branch information
jhawthorn authored Oct 23, 2024
2 parents b943622 + aeac4fc commit 74fceba
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion activerecord/lib/active_record/core.rb
Original file line number Diff line number Diff line change
Expand Up @@ -618,7 +618,7 @@ def ==(comparison_object)
def hash
id = self.id

if primary_key_values_present?
if self.class.composite_primary_key? ? primary_key_values_present? : id
self.class.hash ^ id.hash
else
super
Expand Down

0 comments on commit 74fceba

Please sign in to comment.