Skip to content
This repository has been archived by the owner on Feb 4, 2022. It is now read-only.

Commit

Permalink
Issue #68: Remove objects instead of clearing and re-adding
Browse files Browse the repository at this point in the history
  • Loading branch information
johanjanssens committed May 2, 2016
1 parent 652c9c1 commit b3437e2
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions code/object/set.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,12 +105,10 @@ public function merge(ObjectSet $set)
public function filter(/*Callable*/ $filter)
{
$result = clone $this;
$result->clear();

foreach ($this as $object)
{
if (call_user_func($filter, $object) !== false) {
$result->insert($object);
if (call_user_func($filter, $object) === false) {
$result->remove($object);
}
}

Expand Down

0 comments on commit b3437e2

Please sign in to comment.