Skip to content

Commit e57a67b

Browse files
authored
optimize for loop in WildcardPermission (#2113)
1 parent 074382c commit e57a67b

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/WildcardPermission.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,9 @@ public function implies($permission): bool
4747
$otherParts = $permission->getParts();
4848

4949
$i = 0;
50+
$partsCount = $this->getParts()->count();
5051
foreach ($otherParts as $otherPart) {
51-
if ($this->getParts()->count() - 1 < $i) {
52+
if ($partsCount - 1 < $i) {
5253
return true;
5354
}
5455

@@ -60,7 +61,7 @@ public function implies($permission): bool
6061
$i++;
6162
}
6263

63-
for ($i; $i < $this->parts->count(); $i++) {
64+
for ($i; $i < $partsCount; $i++) {
6465
if (! $this->parts->get($i)->contains(static::WILDCARD_TOKEN)) {
6566
return false;
6667
}

0 commit comments

Comments
 (0)