mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Avoid extra Array allocation
This commit is contained in:
parent
ac206e6dff
commit
c900cdfdc3
1 changed files with 3 additions and 3 deletions
|
@ -48,18 +48,18 @@ module ActiveRecord
|
||||||
raw_records = owner_keys.empty? ? [] : records_for(owner_keys)
|
raw_records = owner_keys.empty? ? [] : records_for(owner_keys)
|
||||||
|
|
||||||
@preloaded_records = raw_records.select do |record|
|
@preloaded_records = raw_records.select do |record|
|
||||||
assignments = []
|
assignments = false
|
||||||
|
|
||||||
owners_by_key[convert_key(record[association_key_name])].each do |owner|
|
owners_by_key[convert_key(record[association_key_name])].each do |owner|
|
||||||
entries = (@records_by_owner[owner] ||= [])
|
entries = (@records_by_owner[owner] ||= [])
|
||||||
|
|
||||||
if reflection.collection? || entries.empty?
|
if reflection.collection? || entries.empty?
|
||||||
entries << record
|
entries << record
|
||||||
assignments << record
|
assignments = true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
!assignments.empty?
|
assignments
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue