Minor tweaks to execution speed, including eliminating a method call on storing a cell
This commit is contained in:
parent
0171709e7f
commit
45be09e98b
|
|
@ -5236,8 +5236,6 @@ class Calculation
|
||||||
$aReferences = Coordinate::extractAllCellReferencesInRange($range);
|
$aReferences = Coordinate::extractAllCellReferencesInRange($range);
|
||||||
$range = "'" . $worksheetName . "'" . '!' . $range;
|
$range = "'" . $worksheetName . "'" . '!' . $range;
|
||||||
if (!isset($aReferences[1])) {
|
if (!isset($aReferences[1])) {
|
||||||
$currentCol = '';
|
|
||||||
$currentRow = 0;
|
|
||||||
// Single cell in range
|
// Single cell in range
|
||||||
sscanf($aReferences[0], '%[A-Z]%d', $currentCol, $currentRow);
|
sscanf($aReferences[0], '%[A-Z]%d', $currentCol, $currentRow);
|
||||||
if ($worksheet->cellExists($aReferences[0])) {
|
if ($worksheet->cellExists($aReferences[0])) {
|
||||||
|
|
@ -5248,8 +5246,6 @@ class Calculation
|
||||||
} else {
|
} else {
|
||||||
// Extract cell data for all cells in the range
|
// Extract cell data for all cells in the range
|
||||||
foreach ($aReferences as $reference) {
|
foreach ($aReferences as $reference) {
|
||||||
$currentCol = '';
|
|
||||||
$currentRow = 0;
|
|
||||||
// Extract range
|
// Extract range
|
||||||
sscanf($reference, '%[A-Z]%d', $currentCol, $currentRow);
|
sscanf($reference, '%[A-Z]%d', $currentCol, $currentRow);
|
||||||
if ($worksheet->cellExists($reference)) {
|
if ($worksheet->cellExists($reference)) {
|
||||||
|
|
|
||||||
|
|
@ -317,7 +317,9 @@ class Cells
|
||||||
|
|
||||||
// Store new values
|
// Store new values
|
||||||
$stored = $newCollection->cache->setMultiple($newValues);
|
$stored = $newCollection->cache->setMultiple($newValues);
|
||||||
$this->destructIfNeeded($stored, $newCollection, 'Failed to copy cells in cache');
|
if ($stored === false) {
|
||||||
|
$this->destructIfNeeded($newCollection, 'Failed to copy cells in cache');
|
||||||
|
}
|
||||||
|
|
||||||
return $newCollection;
|
return $newCollection;
|
||||||
}
|
}
|
||||||
|
|
@ -362,7 +364,9 @@ class Cells
|
||||||
$this->currentCell->detach();
|
$this->currentCell->detach();
|
||||||
|
|
||||||
$stored = $this->cache->set($this->cachePrefix . $this->currentCoordinate, $this->currentCell);
|
$stored = $this->cache->set($this->cachePrefix . $this->currentCoordinate, $this->currentCell);
|
||||||
$this->destructIfNeeded($stored, $this, "Failed to store cell {$this->currentCoordinate} in cache");
|
if ($stored === false) {
|
||||||
|
$this->destructIfNeeded($this, "Failed to store cell {$this->currentCoordinate} in cache");
|
||||||
|
}
|
||||||
$this->currentCellIsDirty = false;
|
$this->currentCellIsDirty = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -370,14 +374,12 @@ class Cells
|
||||||
$this->currentCell = null;
|
$this->currentCell = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function destructIfNeeded(bool $stored, self $cells, string $message): void
|
private function destructIfNeeded(self $cells, string $message): void
|
||||||
{
|
{
|
||||||
if (!$stored) {
|
|
||||||
$cells->__destruct();
|
$cells->__destruct();
|
||||||
|
|
||||||
throw new PhpSpreadsheetException($message);
|
throw new PhpSpreadsheetException($message);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add or update a cell identified by its coordinate into the collection.
|
* Add or update a cell identified by its coordinate into the collection.
|
||||||
|
|
@ -416,7 +418,7 @@ class Cells
|
||||||
$this->storeCurrentCell();
|
$this->storeCurrentCell();
|
||||||
|
|
||||||
// Return null if requested entry doesn't exist in collection
|
// Return null if requested entry doesn't exist in collection
|
||||||
if (!$this->has($cellCoordinate)) {
|
if ($this->has($cellCoordinate) === false) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue