Skip to content

Commit

Permalink
Use iterator_count() instead of a foreach loop.
Browse files Browse the repository at this point in the history
  • Loading branch information
drupol committed Jun 13, 2019
1 parent 43da343 commit a95215f
Showing 1 changed file with 1 addition and 7 deletions.
8 changes: 1 addition & 7 deletions src/Node/Node.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,7 @@ public function children(): \Traversable
*/
public function count(): int
{
$count = -1;

foreach ($this->all() as $node) {
++$count;
}

return $count;
return \iterator_count($this->all()) - 1;
}

/**
Expand Down

0 comments on commit a95215f

Please sign in to comment.