Skip to content

Commit f28289f

Browse files
Matt AllanPowerKiKi
Matt Allan
authored andcommitted
Use a generator for Cells::getAllCacheKeys
Using a generator reduces memory usage and improves performance when loading large spreadsheets. Closes #822
1 parent 8918888 commit f28289f

File tree

2 files changed

+3
-5
lines changed

2 files changed

+3
-5
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ and this project adheres to [Semantic Versioning](https://semver.org).
2020
- Fix VLOOKUP with exact matches - [#809](https://github.com/PHPOffice/PhpSpreadsheet/pull/809)
2121
- Support COUNTIFS multiple arguments - [#830](https://github.com/PHPOffice/PhpSpreadsheet/pull/830)
2222
- Change `libxml_disable_entity_loader()` as shortly as possible - [#819](https://github.com/PHPOffice/PhpSpreadsheet/pull/819)
23+
- Improved memory usage and performance when loading large spreadsheets - [#822](https://github.com/PHPOffice/PhpSpreadsheet/pull/822)
2324

2425
## [1.5.2] - 2018-11-25
2526

src/PhpSpreadsheet/Collection/Cells.php

+2-5
Original file line numberDiff line numberDiff line change
@@ -495,15 +495,12 @@ public function __destruct()
495495
/**
496496
* Returns all known cache keys.
497497
*
498-
* @return string[]
498+
* @return \Generator|string[]
499499
*/
500500
private function getAllCacheKeys()
501501
{
502-
$keys = [];
503502
foreach ($this->getCoordinates() as $coordinate) {
504-
$keys[] = $this->cachePrefix . $coordinate;
503+
yield $this->cachePrefix . $coordinate;
505504
}
506-
507-
return $keys;
508505
}
509506
}

0 commit comments

Comments
 (0)