DDC-814: Collection: Storage of entities #1005

Closed
opened 2026-01-22 12:58:37 +01:00 by admin · 2 comments
Owner

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.

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.
admin added the Improvement label 2026-01-22 12:58:37 +01:00
admin closed this issue 2026-01-22 12:58:38 +01:00
Author
Owner

@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): 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.
Author
Owner

@doctrinebot commented on GitHub (Sep 24, 2010):

Issue was closed with resolution "Won't Fix"

@doctrinebot commented on GitHub (Sep 24, 2010): Issue was closed with resolution "Won't Fix"
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#1005