aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/ramsey/collection/src/AbstractSet.php
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/ramsey/collection/src/AbstractSet.php')
-rw-r--r--vendor/ramsey/collection/src/AbstractSet.php19
1 files changed, 10 insertions, 9 deletions
diff --git a/vendor/ramsey/collection/src/AbstractSet.php b/vendor/ramsey/collection/src/AbstractSet.php
index 1126ccb0a..63f833156 100644
--- a/vendor/ramsey/collection/src/AbstractSet.php
+++ b/vendor/ramsey/collection/src/AbstractSet.php
@@ -24,22 +24,23 @@ namespace Ramsey\Collection;
*/
abstract class AbstractSet extends AbstractCollection
{
- /**
- * @inheritDoc
- */
- public function add($element): bool
+ public function add(mixed $element): bool
{
if ($this->contains($element)) {
return false;
}
- return parent::add($element);
+ // Call offsetSet() on the parent instead of add(), since calling
+ // parent::add() will invoke $this->offsetSet(), which will call
+ // $this->contains() a second time. This can cause performance issues
+ // with extremely large collections. For more information, see
+ // https://github.com/ramsey/collection/issues/68.
+ parent::offsetSet(null, $element);
+
+ return true;
}
- /**
- * @inheritDoc
- */
- public function offsetSet($offset, $value): void
+ public function offsetSet(mixed $offset, mixed $value): void
{
if ($this->contains($value)) {
return;