Remove duplicate strtoupper
Removing the duplicate strtoupper call has a meaningful impact on performance since this method is called at least once per cell. `Worksheet::getCells` currently calls `strtoupper` twice. `strtoupper` is kind of expensive and this method is called at least once for every cell in the spreadsheet. By removing the unnecessary second call the runtime decreases by 18% when importing a ~100K cell spreadsheet. Closes #825
This commit is contained in:
parent
e8c25c33cd
commit
ff6f4f4ec0
|
@ -21,6 +21,7 @@ and this project adheres to [Semantic Versioning](https://semver.org).
|
||||||
- Support COUNTIFS multiple arguments - [#830](https://github.com/PHPOffice/PhpSpreadsheet/pull/830)
|
- 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)
|
- 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 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)
|
||||||
|
|
||||||
## [1.5.2] - 2018-11-25
|
## [1.5.2] - 2018-11-25
|
||||||
|
|
||||||
|
|
|
@ -1191,9 +1191,12 @@ class Worksheet implements IComparable
|
||||||
*/
|
*/
|
||||||
public function getCell($pCoordinate, $createIfNotExists = true)
|
public function getCell($pCoordinate, $createIfNotExists = true)
|
||||||
{
|
{
|
||||||
|
// Uppercase coordinate
|
||||||
|
$pCoordinateUpper = strtoupper($pCoordinate);
|
||||||
|
|
||||||
// Check cell collection
|
// Check cell collection
|
||||||
if ($this->cellCollection->has(strtoupper($pCoordinate))) {
|
if ($this->cellCollection->has($pCoordinateUpper)) {
|
||||||
return $this->cellCollection->get($pCoordinate);
|
return $this->cellCollection->get($pCoordinateUpper);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Worksheet reference?
|
// Worksheet reference?
|
||||||
|
@ -1214,9 +1217,6 @@ class Worksheet implements IComparable
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Uppercase coordinate
|
|
||||||
$pCoordinate = strtoupper($pCoordinate);
|
|
||||||
|
|
||||||
if (Coordinate::coordinateIsRange($pCoordinate)) {
|
if (Coordinate::coordinateIsRange($pCoordinate)) {
|
||||||
throw new Exception('Cell coordinate can not be a range of cells.');
|
throw new Exception('Cell coordinate can not be a range of cells.');
|
||||||
} elseif (strpos($pCoordinate, '$') !== false) {
|
} elseif (strpos($pCoordinate, '$') !== false) {
|
||||||
|
@ -1224,7 +1224,7 @@ class Worksheet implements IComparable
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create new cell object, if required
|
// Create new cell object, if required
|
||||||
return $createIfNotExists ? $this->createNewCell($pCoordinate) : null;
|
return $createIfNotExists ? $this->createNewCell($pCoordinateUpper) : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue