From e3b15694c0f0a10f88b9fcbc38effcc63c79fdee Mon Sep 17 00:00:00 2001 From: Mark Baker Date: Tue, 26 Oct 2010 15:40:55 +0000 Subject: [PATCH] Minor performance tweaks git-svn-id: https://phpexcel.svn.codeplex.com/svn/trunk@62816 2327b42d-5241-43d6-9e2a-de5ac946f064 --- Classes/PHPExcel/Cell.php | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/Classes/PHPExcel/Cell.php b/Classes/PHPExcel/Cell.php index dc24dec9..be5e2bcc 100644 --- a/Classes/PHPExcel/Cell.php +++ b/Classes/PHPExcel/Cell.php @@ -627,20 +627,17 @@ class PHPExcel_Cell 'N' => 14, 'O' => 15, 'P' => 16, 'Q' => 17, 'R' => 18, 'S' => 19, 'T' => 20, 'U' => 21, 'V' => 22, 'W' => 23, 'X' => 24, 'Y' => 25, 'Z' => 26 ); - if (isset($lookup[$pString])) - return $lookup[$pString]; - // Convert to uppercase $pString = strtoupper($pString); $strLen = strlen($pString); // Convert column to integer if ($strLen == 1) { - return (ord($pString{0}) - 64); + return $lookup[$pString]; } elseif ($strLen == 2) { - return $result = ((1 + (ord($pString{0}) - 65)) * 26) + (ord($pString{1}) - 64); + return $lookup[$pString{0}] * 26 + $lookup[$pString{1}]; } elseif ($strLen == 3) { - return ((1 + (ord($pString{0}) - 65)) * 676) + ((1 + (ord($pString{1}) - 65)) * 26) + (ord($pString{2}) - 64); + return $lookup[$pString{0}] * 676 + $lookup[$pString{1}] * 26 + $lookup[$pString{2}]; } else { throw new Exception("Column string index can not be " . ($strLen != 0 ? "longer than 3 characters" : "empty") . "."); }