Skip to content

Commit 90f7ba2

Browse files
committed
Fixed adjust capacity
1 parent 5856c56 commit 90f7ba2

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

src/Traits/Capacity.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public function allocate(int $capacity)
3939
/**
4040
* Called when capacity should be increased to accommodate new values.
4141
*/
42-
abstract protected function increaseCapacityWhenFull();
42+
abstract protected function increaseCapacity();
4343

4444
/**
4545
* Adjusts the structure's capacity according to its current size.
@@ -55,8 +55,8 @@ private function adjustCapacity()
5555
} else {
5656

5757
// Also check if we should increase capacity when the size changes.
58-
while ($size >= $this->capacity) {
59-
$this->increaseCapacityWhenFull();
58+
if ($size >= $this->capacity) {
59+
$this->increaseCapacity();
6060
}
6161
}
6262
}

src/Traits/SquaredCapacity.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public function allocate(int $capacity)
3636
/**
3737
* Called when capacity should be increased to accommodate new values.
3838
*/
39-
protected function increaseCapacityWhenFull()
39+
protected function increaseCapacity()
4040
{
4141
$this->capacity = $this->square(max(count($this), $this->capacity + 1));
4242
}

src/Vector.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ final class Vector implements \IteratorAggregate, \ArrayAccess, Sequence
1717
/**
1818
* Increase capacity
1919
*/
20-
protected function increaseCapacityWhenFull()
20+
protected function increaseCapacity()
2121
{
2222
$size = count($this);
2323

0 commit comments

Comments
 (0)