#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)
|
private function restoreNewObjectsInDirtyCollection(array $newObjects)
|
||||||
{
|
{
|
||||||
$loadedObjects = $this->collection->toArray();
|
$loadedObjects = $this->collection->toArray();
|
||||||
$newObjectsByOid = array_combine(array_map('spl_object_hash', $newObjects), $newObjects);
|
$newObjectsByOid = \array_combine(\array_map('spl_object_hash', $newObjects), $newObjects);
|
||||||
$loadedObjectsByOid = array_combine(array_map('spl_object_hash', $loadedObjects), $loadedObjects);
|
$loadedObjectsByOid = \array_combine(\array_map('spl_object_hash', $loadedObjects), $loadedObjects);
|
||||||
$newObjectsThatWereNotLoaded = array_diff_key($newObjectsByOid, $loadedObjectsByOid);
|
$newObjectsThatWereNotLoaded = \array_diff_key($newObjectsByOid, $loadedObjectsByOid);
|
||||||
|
|
||||||
// Reattach NEW objects added through add(), if any.
|
if ($newObjectsThatWereNotLoaded) {
|
||||||
array_walk($newObjectsThatWereNotLoaded, [$this->collection, 'add']);
|
// 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