From 0f8292fc0bdfd387126c6c557bdbaf570dd08c66 Mon Sep 17 00:00:00 2001 From: Matt Allan Date: Tue, 18 Dec 2018 12:59:19 -0500 Subject: [PATCH] Use gt operator instead of max for highest row Using an operator is significantly faster than calling the max function. As this method is called more than once per cell the difference adds up. Closes #824 --- CHANGELOG.md | 1 + src/PhpSpreadsheet/Worksheet/Worksheet.php | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5d1553d0..7483ac3a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,7 @@ and this project adheres to [Semantic Versioning](https://semver.org). - 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) - Improved performance when loading large spreadsheets - [#825](https://github.com/PHPOffice/PhpSpreadsheet/pull/825) +- Improved performance when loading large spreadsheets - [#824](https://github.com/PHPOffice/PhpSpreadsheet/pull/824) ## [1.5.2] - 2018-11-25 diff --git a/src/PhpSpreadsheet/Worksheet/Worksheet.php b/src/PhpSpreadsheet/Worksheet/Worksheet.php index dd233901..d0224037 100644 --- a/src/PhpSpreadsheet/Worksheet/Worksheet.php +++ b/src/PhpSpreadsheet/Worksheet/Worksheet.php @@ -1268,7 +1268,9 @@ class Worksheet implements IComparable if (Coordinate::columnIndexFromString($this->cachedHighestColumn) < Coordinate::columnIndexFromString($aCoordinates[0])) { $this->cachedHighestColumn = $aCoordinates[0]; } - $this->cachedHighestRow = max($this->cachedHighestRow, $aCoordinates[1]); + if ($aCoordinates[1] > $this->cachedHighestRow) { + $this->cachedHighestRow = $aCoordinates[1]; + } // Cell needs appropriate xfIndex from dimensions records // but don't create dimension records if they don't already exist