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:
commit
0fc31fe28a
1 changed files with 2 additions and 0 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue