Minor performance tweaks

This commit is contained in:
Mark Baker 2013-04-26 12:44:47 +01:00
parent 8a05ee8896
commit 8debf76a8a
5 changed files with 15 additions and 15 deletions

View File

@ -177,7 +177,7 @@ abstract class PHPExcel_CachedObjectStorage_CacheBase {
public function getSortedCellList() { public function getSortedCellList() {
$sortKeys = array(); $sortKeys = array();
foreach ($this->getCellList() as $coord) { foreach ($this->getCellList() as $coord) {
list($column,$row) = sscanf($coord,'%[A-Z]%d'); sscanf($coord,'%[A-Z]%d', $column, $row);
$sortKeys[sprintf('%09d%3s',$row,$column)] = $coord; $sortKeys[sprintf('%09d%3s',$row,$column)] = $coord;
} }
ksort($sortKeys); ksort($sortKeys);
@ -198,7 +198,7 @@ abstract class PHPExcel_CachedObjectStorage_CacheBase {
$col = array('A' => '1A'); $col = array('A' => '1A');
$row = array(1); $row = array(1);
foreach ($this->getCellList() as $coord) { foreach ($this->getCellList() as $coord) {
list($c,$r) = sscanf($coord,'%[A-Z]%d'); sscanf($coord,'%[A-Z]%d', $c, $r);
$row[$r] = $r; $row[$r] = $r;
$col[$c] = strlen($c).$c; $col[$c] = strlen($c).$c;
} }
@ -221,13 +221,13 @@ abstract class PHPExcel_CachedObjectStorage_CacheBase {
public function getCurrentColumn() public function getCurrentColumn()
{ {
list($column,$row) = sscanf($this->_currentObjectID, '%[A-Z]%d'); sscanf($this->_currentObjectID, '%[A-Z]%d', $column, $row);
return $column; return $column;
} }
public function getCurrentRow() public function getCurrentRow()
{ {
list($column,$row) = sscanf($this->_currentObjectID, '%[A-Z]%d'); sscanf($this->_currentObjectID, '%[A-Z]%d', $column, $row);
return $row; return $row;
} }

View File

@ -3621,7 +3621,7 @@ class PHPExcel_Calculation {
$pRange = $pSheetName.'!'.$pRange; $pRange = $pSheetName.'!'.$pRange;
if (!isset($aReferences[1])) { if (!isset($aReferences[1])) {
// Single cell in range // Single cell in range
list($currentCol,$currentRow) = sscanf($aReferences[0],'%[A-Z]%d'); sscanf($aReferences[0],'%[A-Z]%d', $currentCol, $currentRow);
$cellValue = NULL; $cellValue = NULL;
if ($pSheet->cellExists($aReferences[0])) { if ($pSheet->cellExists($aReferences[0])) {
$returnValue[$currentRow][$currentCol] = $pSheet->getCell($aReferences[0])->getCalculatedValue($resetLog); $returnValue[$currentRow][$currentCol] = $pSheet->getCell($aReferences[0])->getCalculatedValue($resetLog);
@ -3632,7 +3632,7 @@ class PHPExcel_Calculation {
// 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) {
// Extract range // Extract range
list($currentCol,$currentRow) = sscanf($reference,'%[A-Z]%d'); sscanf($reference,'%[A-Z]%d', $currentCol, $currentRow);
$cellValue = NULL; $cellValue = NULL;
if ($pSheet->cellExists($reference)) { if ($pSheet->cellExists($reference)) {
$returnValue[$currentRow][$currentCol] = $pSheet->getCell($reference)->getCalculatedValue($resetLog); $returnValue[$currentRow][$currentCol] = $pSheet->getCell($reference)->getCalculatedValue($resetLog);

View File

@ -822,8 +822,8 @@ class PHPExcel_Cell
// Range... // Range...
list($rangeStart, $rangeEnd) = $range; list($rangeStart, $rangeEnd) = $range;
list($startCol, $startRow) = sscanf($rangeStart,'%[A-Z]%d'); sscanf($rangeStart,'%[A-Z]%d', $startCol, $startRow);
list($endCol, $endRow) = sscanf($rangeEnd,'%[A-Z]%d'); sscanf($rangeEnd,'%[A-Z]%d', $endCol, $endRow);
$endCol++; $endCol++;
// Current data // Current data
@ -845,7 +845,7 @@ class PHPExcel_Cell
// Sort the result by column and row // Sort the result by column and row
$sortKeys = array(); $sortKeys = array();
foreach (array_unique($returnValue) as $coord) { foreach (array_unique($returnValue) as $coord) {
list($column,$row) = sscanf($coord,'%[A-Z]%d'); sscanf($coord,'%[A-Z]%d', $column, $row);
$sortKeys[sprintf('%3s%09d',$column,$row)] = $coord; $sortKeys[sprintf('%3s%09d',$column,$row)] = $coord;
} }
ksort($sortKeys); ksort($sortKeys);

View File

@ -101,8 +101,8 @@ class PHPExcel_ReferenceHelper
* @return integer * @return integer
*/ */
public static function cellSort($a, $b) { public static function cellSort($a, $b) {
list($ac,$ar) = sscanf($a,'%[A-Z]%d'); sscanf($a,'%[A-Z]%d', $ac, $ar);
list($bc,$br) = sscanf($b,'%[A-Z]%d'); sscanf($b,'%[A-Z]%d', $bc, $br);
if ($ar == $br) { if ($ar == $br) {
return strcasecmp(strlen($ac) . $ac, strlen($bc) . $bc); return strcasecmp(strlen($ac) . $ac, strlen($bc) . $bc);
@ -119,8 +119,8 @@ class PHPExcel_ReferenceHelper
* @return integer * @return integer
*/ */
public static function cellReverseSort($a, $b) { public static function cellReverseSort($a, $b) {
list($ac,$ar) = sscanf($a,'%[A-Z]%d'); sscanf($a,'%[A-Z]%d', $ac, $ar);
list($bc,$br) = sscanf($b,'%[A-Z]%d'); sscanf($b,'%[A-Z]%d', $bc, $br);
if ($ar == $br) { if ($ar == $br) {
return 1 - strcasecmp(strlen($ac) . $ac, strlen($bc) . $bc); return 1 - strcasecmp(strlen($ac) . $ac, strlen($bc) . $bc);
@ -549,7 +549,7 @@ class PHPExcel_ReferenceHelper
if ($pNumCols != 0) { if ($pNumCols != 0) {
$autoFilterColumns = array_keys($autoFilter->getColumns()); $autoFilterColumns = array_keys($autoFilter->getColumns());
if (count($autoFilterColumns) > 0) { if (count($autoFilterColumns) > 0) {
list($column,$row) = sscanf($pBefore,'%[A-Z]%d'); sscanf($pBefore,'%[A-Z]%d', $column, $row);
$columnIndex = PHPExcel_Cell::columnIndexFromString($column); $columnIndex = PHPExcel_Cell::columnIndexFromString($column);
list($rangeStart,$rangeEnd) = PHPExcel_Cell::rangeBoundaries($autoFilterRange); list($rangeStart,$rangeEnd) = PHPExcel_Cell::rangeBoundaries($autoFilterRange);
if ($columnIndex <= $rangeEnd[0]) { if ($columnIndex <= $rangeEnd[0]) {

View File

@ -725,7 +725,7 @@ class PHPExcel_Worksheet_AutoFilter
// Date based // Date based
if ($dynamicRuleType{0} == 'M' || $dynamicRuleType{0} == 'Q') { if ($dynamicRuleType{0} == 'M' || $dynamicRuleType{0} == 'Q') {
// Month or Quarter // Month or Quarter
list($periodType,$period) = sscanf($dynamicRuleType,'%[A-Z]%d'); sscanf($dynamicRuleType,'%[A-Z]%d', $periodType, $period);
if ($periodType == 'M') { if ($periodType == 'M') {
$ruleValues = array($period); $ruleValues = array($period);
} else { } else {