1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Merge pull request #42719 from jdelStrother/hash-optimization

Micro-optimize ActiveRecord::Core#hash
This commit is contained in:
Rafael França 2021-07-07 15:06:49 -04:00 committed by GitHub
commit 0fc31fe28a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -601,6 +601,8 @@ module ActiveRecord
# Delegates to id in order to allow two records of the same type and id to work with something like:
# [ Person.find(1), Person.find(2), Person.find(3) ] & [ Person.find(1), Person.find(4) ] # => [ Person.find(1) ]
def hash
id = self.id
if id
self.class.hash ^ id.hash
else