Skip to content

Commit

Permalink
Merge pull request #89 from wmde/diffIsEmpty
Browse files Browse the repository at this point in the history
Optimize Diff::isEmpty for performance
  • Loading branch information
JeroenDeDauw committed Jan 23, 2018
2 parents 3ebfae8 + 7b57a52 commit 59f2616
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/DiffOp/Diff/Diff.php
Expand Up @@ -450,14 +450,19 @@ public function serialize() {
}

/**
* Returns if the ArrayObject has no elements.
*
* @since 0.1
*
* @return bool
*/
public function isEmpty(): bool {
return $this->count() === 0;
/** @var DiffOp $diffOp */
foreach ( $this as $diffOp ) {
if ( $diffOp->count() > 0 ) {
return false;
}
}

return true;
}

}

0 comments on commit 59f2616

Please sign in to comment.