Minor performance tweaks

git-svn-id: https://phpexcel.svn.codeplex.com/svn/trunk@62808 2327b42d-5241-43d6-9e2a-de5ac946f064
This commit is contained in:
Mark Baker 2010-10-26 12:29:44 +00:00
parent 0a826fe9a6
commit 42b1e0ad76
2 changed files with 12 additions and 22 deletions

View File

@ -533,18 +533,15 @@ class PHPExcel_Shared_String
public static function CountCharacters($value, $enc = 'UTF-8') public static function CountCharacters($value, $enc = 'UTF-8')
{ {
if (self::getIsIconvEnabled()) { if (self::getIsIconvEnabled()) {
$count = iconv_strlen($value, $enc); return iconv_strlen($value, $enc);
return $count;
} }
if (self::getIsMbstringEnabled()) { if (self::getIsMbstringEnabled()) {
$count = mb_strlen($value, $enc); return mb_strlen($value, $enc);
return $count;
} }
// else strlen // else strlen
$count = strlen($value); return strlen($value);
return $count;
} }
/** /**
@ -558,18 +555,15 @@ class PHPExcel_Shared_String
public static function Substring($pValue = '', $pStart = 0, $pLength = 0) public static function Substring($pValue = '', $pStart = 0, $pLength = 0)
{ {
if (self::getIsIconvEnabled()) { if (self::getIsIconvEnabled()) {
$string = iconv_substr($pValue, $pStart, $pLength, 'UTF-8'); return iconv_substr($pValue, $pStart, $pLength, 'UTF-8');
return $string;
} }
if (self::getIsMbstringEnabled()) { if (self::getIsMbstringEnabled()) {
$string = mb_substr($pValue, $pStart, $pLength, 'UTF-8'); return mb_substr($pValue, $pStart, $pLength, 'UTF-8');
return $string;
} }
// else substr // else substr
$string = substr($pValue, $pStart, $pLength); return substr($pValue, $pStart, $pLength);
return $string;
} }

View File

@ -2089,22 +2089,18 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
if (is_array($source)) { if (is_array($source)) {
// start coordinate // start coordinate
list ($startColumn, $startRow) = PHPExcel_Cell::coordinateFromString($pCell); list ($startColumn, $startRow) = PHPExcel_Cell::coordinateFromString($pCell);
$startColumn = PHPExcel_Cell::columnIndexFromString($startColumn) - 1;
// Loop through $source // Loop through $source
$currentRow = $startRow - 1;
$rowData = null;
foreach ($source as $rowData) { foreach ($source as $rowData) {
++$currentRow; $currentColumn = $startColumn;
foreach($rowData as $cellValue) {
$rowCount = count($rowData); if ($cellValue != $nullValue) {
for ($i = 0; $i < $rowCount; ++$i) {
if ($rowData[$i] != $nullValue) {
// Set cell value // Set cell value
$this->getCell(PHPExcel_Cell::stringFromColumnIndex($i + $startColumn) . $currentRow) $this->getCell($currentColumn . $startRow)->setValue($cellValue);
->setValue($rowData[$i]);
} }
++$currentColumn;
} }
++$startRow;
} }
} else { } else {
throw new Exception("Parameter \$source should be an array."); throw new Exception("Parameter \$source should be an array.");