1
0
Fork 0
mirror of synced 2025-04-01 20:36:14 +03:00

DDC-1210 - Optimize UnitOfWork collection handling internally.

This commit is contained in:
Benjamin Eberlei 2011-10-15 21:47:16 +02:00
parent 7c244abc1c
commit 4474d305cb

View file

@ -490,8 +490,9 @@ class UnitOfWork implements PropertyChangedListener
}
} else if ($orgValue instanceof PersistentCollection && $orgValue !== $actualValue) {
// A PersistentCollection was de-referenced, so delete it.
if ( ! in_array($orgValue, $this->collectionDeletions, true)) {
$this->collectionDeletions[] = $orgValue;
$coid = spl_object_hash($orgValue);
if ( ! isset($this->collectionDeletions[$coid]) ) {
$this->collectionDeletions[$coid] = $orgValue;
$changeSet[$propName] = $orgValue; // Signal changeset, to-many assocs will be ignored.
}
}
@ -569,10 +570,11 @@ class UnitOfWork implements PropertyChangedListener
private function computeAssociationChanges($assoc, $value)
{
if ($value instanceof PersistentCollection && $value->isDirty()) {
$coid = spl_object_hash($value);
if ($assoc['isOwningSide']) {
$this->collectionUpdates[] = $value;
$this->collectionUpdates[$coid] = $value;
}
$this->visitedCollections[] = $value;
$this->visitedCollections[$coid] = $value;
}
// Look through the entities, and in any of their associations, for transient (new)
@ -1889,12 +1891,12 @@ class UnitOfWork implements PropertyChangedListener
{
//TODO: if $coll is already scheduled for recreation ... what to do?
// Just remove $coll from the scheduled recreations?
$this->collectionDeletions[] = $coll;
$this->collectionDeletions[spl_object_hash($coll)] = $coll;
}
public function isCollectionScheduledForDeletion(PersistentCollection $coll)
{
return in_array($coll, $this->collectionsDeletions, true);
return isset( $this->collectionsDeletions[spl_object_hash($coll)] );
}
/**