Use a generator for Cells::getAllCacheKeys

Using a generator reduces memory usage and improves performance
when loading large spreadsheets.

Closes #822
This commit is contained in:
Matt Allan 2018-12-18 10:35:07 -05:00 committed by Adrien Crivelli
parent 8918888e7c
commit f28289f92a
No known key found for this signature in database
GPG Key ID: B182FD79DC6DE92E
2 changed files with 3 additions and 5 deletions

View File

@ -20,6 +20,7 @@ and this project adheres to [Semantic Versioning](https://semver.org).
- Fix VLOOKUP with exact matches - [#809](https://github.com/PHPOffice/PhpSpreadsheet/pull/809)
- Support COUNTIFS multiple arguments - [#830](https://github.com/PHPOffice/PhpSpreadsheet/pull/830)
- Change `libxml_disable_entity_loader()` as shortly as possible - [#819](https://github.com/PHPOffice/PhpSpreadsheet/pull/819)
- Improved memory usage and performance when loading large spreadsheets - [#822](https://github.com/PHPOffice/PhpSpreadsheet/pull/822)
## [1.5.2] - 2018-11-25

View File

@ -495,15 +495,12 @@ class Cells
/**
* Returns all known cache keys.
*
* @return string[]
* @return \Generator|string[]
*/
private function getAllCacheKeys()
{
$keys = [];
foreach ($this->getCoordinates() as $coordinate) {
$keys[] = $this->cachePrefix . $coordinate;
yield $this->cachePrefix . $coordinate;
}
return $keys;
}
}