#6613 #6614 #6616 minor performance optimisations around the new restoreNewObjectsInDirtyCollection
implementation
This commit is contained in:
parent
ab63628960
commit
5cacb6e14f
@ -712,13 +712,15 @@ final class PersistentCollection extends AbstractLazyCollection implements Selec
|
||||
private function restoreNewObjectsInDirtyCollection(array $newObjects)
|
||||
{
|
||||
$loadedObjects = $this->collection->toArray();
|
||||
$newObjectsByOid = array_combine(array_map('spl_object_hash', $newObjects), $newObjects);
|
||||
$loadedObjectsByOid = array_combine(array_map('spl_object_hash', $loadedObjects), $loadedObjects);
|
||||
$newObjectsThatWereNotLoaded = array_diff_key($newObjectsByOid, $loadedObjectsByOid);
|
||||
$newObjectsByOid = \array_combine(\array_map('spl_object_hash', $newObjects), $newObjects);
|
||||
$loadedObjectsByOid = \array_combine(\array_map('spl_object_hash', $loadedObjects), $loadedObjects);
|
||||
$newObjectsThatWereNotLoaded = \array_diff_key($newObjectsByOid, $loadedObjectsByOid);
|
||||
|
||||
// Reattach NEW objects added through add(), if any.
|
||||
array_walk($newObjectsThatWereNotLoaded, [$this->collection, 'add']);
|
||||
if ($newObjectsThatWereNotLoaded) {
|
||||
// Reattach NEW objects added through add(), if any.
|
||||
\array_walk($newObjectsThatWereNotLoaded, [$this->collection, 'add']);
|
||||
|
||||
$this->isDirty = (bool) $newObjectsThatWereNotLoaded;
|
||||
$this->isDirty = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user