Performance tweaks to calculating column string from index
This commit is contained in:
parent
a0ad01e91d
commit
55f03a5d38
|
|
@ -324,6 +324,7 @@ abstract class Coordinate
|
||||||
public static function stringFromColumnIndex($columnIndex)
|
public static function stringFromColumnIndex($columnIndex)
|
||||||
{
|
{
|
||||||
static $indexCache = [];
|
static $indexCache = [];
|
||||||
|
static $lookupCache = ' ABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
||||||
|
|
||||||
if (!isset($indexCache[$columnIndex])) {
|
if (!isset($indexCache[$columnIndex])) {
|
||||||
$indexValue = $columnIndex;
|
$indexValue = $columnIndex;
|
||||||
|
|
@ -331,7 +332,7 @@ abstract class Coordinate
|
||||||
do {
|
do {
|
||||||
$characterValue = ($indexValue % 26) ?: 26;
|
$characterValue = ($indexValue % 26) ?: 26;
|
||||||
$indexValue = ($indexValue - $characterValue) / 26;
|
$indexValue = ($indexValue - $characterValue) / 26;
|
||||||
$base26 = chr($characterValue + 64) . $base26;
|
$base26 = $lookupCache[$characterValue] . $base26;
|
||||||
} while ($indexValue > 0);
|
} while ($indexValue > 0);
|
||||||
$indexCache[$columnIndex] = $base26;
|
$indexCache[$columnIndex] = $base26;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue