mirror of
https://github.com/doctrine/orm.git
synced 2026-03-24 06:52:09 +01:00
DDC-814: Collection: Storage of entities #1005
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @doctrinebot on GitHub (Sep 24, 2010).
Jira issue originally created by user mazatwork:
The Collection class should store the entities more efficiently.
public function add($entity)
{
$this->_elements[spl_object_hash($entity)] = $entity;
}
This allows methods like contains() and removeElement() to execute with O(1). The primary goal of collections is to work with entities and not to deal with (numeric) keys.
Thank you.
@doctrinebot commented on GitHub (Sep 24, 2010):
Comment created by romanb:
No, a Collection is semantically an OO PHP array. Besides, when you have very large (persistent) collections the performance problems are completely elsewhere (db access, hydration, ...). Moreover spl_object_hash is not a good candidate for collection keys as the hashes of destroyed objects can be reused in the same script.
@doctrinebot commented on GitHub (Sep 24, 2010):
Issue was closed with resolution "Won't Fix"