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

View File

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