Skip to content

Commit

Permalink
Revert "minor refactoring, simplify further"
Browse files Browse the repository at this point in the history
This reverts commit 9ee0eaa.
  • Loading branch information
drupol committed Jan 19, 2024
1 parent 69991e8 commit 22a5c47
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/SimpleCachingIteratorAggregate.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,18 @@ public function getIterator(): Generator

yield $key = $this->iterator->key() => $this->iterator->current();

$cache = $this->iterator->getCache();

if (array_key_last($cache) === $key) {
continue;
}

// If the cache pointer has shifted since last iteration
// (inner loop over the same iterator), it's necessary to yield
// extra-cached items as well
$yieldStarted = false;

foreach ($this->iterator->getCache() as $cacheKey => $cacheItem) {
foreach ($cache as $cacheKey => $cacheItem) {
if ($yieldStarted) {
yield $cacheKey => $cacheItem;
}
Expand Down

0 comments on commit 22a5c47

Please sign in to comment.