mirror of
https://github.com/retailcrm/PHPExcel.git
synced 2024-11-30 01:06:03 +03:00
Minor performance tweaks
git-svn-id: https://phpexcel.svn.codeplex.com/svn/trunk@85527 2327b42d-5241-43d6-9e2a-de5ac946f064
This commit is contained in:
parent
34f3e8b706
commit
508be392e7
@ -21,7 +21,7 @@
|
|||||||
* @category PHPExcel
|
* @category PHPExcel
|
||||||
* @package PHPExcel
|
* @package PHPExcel
|
||||||
* @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
|
* @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version ##VERSION##, ##DATE##
|
* @version ##VERSION##, ##DATE##
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -29,35 +29,39 @@ PHPExcel_Autoloader::Register();
|
|||||||
PHPExcel_Shared_ZipStreamWrapper::register();
|
PHPExcel_Shared_ZipStreamWrapper::register();
|
||||||
// check mbstring.func_overload
|
// check mbstring.func_overload
|
||||||
if (ini_get('mbstring.func_overload') & 2) {
|
if (ini_get('mbstring.func_overload') & 2) {
|
||||||
throw new Exception('Multibyte function overloading in PHP must be disabled for string functions (2).');
|
throw new Exception('Multibyte function overloading in PHP must be disabled for string functions (2).');
|
||||||
}
|
}
|
||||||
PHPExcel_Shared_String::buildCharacterSets();
|
PHPExcel_Shared_String::buildCharacterSets();
|
||||||
|
|
||||||
|
|
||||||
class PHPExcel_Autoloader
|
class PHPExcel_Autoloader
|
||||||
{
|
{
|
||||||
public static function Register() {
|
public static function Register() {
|
||||||
if (function_exists('__autoload')) {
|
if (function_exists('__autoload')) {
|
||||||
spl_autoload_register('__autoload');
|
// Register any existing autoloader function with SPL, so we don't get any clashes
|
||||||
}
|
spl_autoload_register('__autoload');
|
||||||
return spl_autoload_register(array('PHPExcel_Autoloader', 'Load'));
|
}
|
||||||
} // function Register()
|
// Register ourselves with SPL
|
||||||
|
return spl_autoload_register(array('PHPExcel_Autoloader', 'Load'));
|
||||||
|
} // function Register()
|
||||||
|
|
||||||
|
|
||||||
public static function Load($pObjectName){
|
public static function Load($pObjectName){
|
||||||
if ((class_exists($pObjectName)) || (strpos($pObjectName, 'PHPExcel') === False)) {
|
if ((class_exists($pObjectName)) || (strpos($pObjectName, 'PHPExcel') !== 0)) {
|
||||||
return false;
|
// Either already loaded, or not a PHPExcel class request
|
||||||
}
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
$pObjectFilePath = PHPEXCEL_ROOT.
|
$pObjectFilePath = PHPEXCEL_ROOT .
|
||||||
str_replace('_',DIRECTORY_SEPARATOR,$pObjectName).
|
str_replace('_',DIRECTORY_SEPARATOR,$pObjectName) .
|
||||||
'.php';
|
'.php';
|
||||||
|
|
||||||
if ((file_exists($pObjectFilePath) === false) || (is_readable($pObjectFilePath) === false)) {
|
if ((file_exists($pObjectFilePath) === false) || (is_readable($pObjectFilePath) === false)) {
|
||||||
return false;
|
// Can't load
|
||||||
}
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
require($pObjectFilePath);
|
require($pObjectFilePath);
|
||||||
} // function Load()
|
} // function Load()
|
||||||
|
|
||||||
}
|
}
|
@ -58,7 +58,7 @@ class PHPExcel_Calculation_Logical {
|
|||||||
* @return boolean True
|
* @return boolean True
|
||||||
*/
|
*/
|
||||||
public static function TRUE() {
|
public static function TRUE() {
|
||||||
return true;
|
return TRUE;
|
||||||
} // function TRUE()
|
} // function TRUE()
|
||||||
|
|
||||||
|
|
||||||
@ -75,7 +75,7 @@ class PHPExcel_Calculation_Logical {
|
|||||||
* @return boolean False
|
* @return boolean False
|
||||||
*/
|
*/
|
||||||
public static function FALSE() {
|
public static function FALSE() {
|
||||||
return false;
|
return FALSE;
|
||||||
} // function FALSE()
|
} // function FALSE()
|
||||||
|
|
||||||
|
|
||||||
@ -102,12 +102,12 @@ class PHPExcel_Calculation_Logical {
|
|||||||
*/
|
*/
|
||||||
public static function LOGICAL_AND() {
|
public static function LOGICAL_AND() {
|
||||||
// Return value
|
// Return value
|
||||||
$returnValue = True;
|
$returnValue = TRUE;
|
||||||
|
|
||||||
// Loop through the arguments
|
// Loop through the arguments
|
||||||
$aArgs = PHPExcel_Calculation_Functions::flattenArray(func_get_args());
|
$aArgs = PHPExcel_Calculation_Functions::flattenArray(func_get_args());
|
||||||
$argCount = 0;
|
$argCount = -1;
|
||||||
foreach ($aArgs as $arg) {
|
foreach ($aArgs as $argCount => $arg) {
|
||||||
// Is it a boolean value?
|
// Is it a boolean value?
|
||||||
if (is_bool($arg)) {
|
if (is_bool($arg)) {
|
||||||
$returnValue = $returnValue && $arg;
|
$returnValue = $returnValue && $arg;
|
||||||
@ -116,19 +116,18 @@ class PHPExcel_Calculation_Logical {
|
|||||||
} elseif (is_string($arg)) {
|
} elseif (is_string($arg)) {
|
||||||
$arg = strtoupper($arg);
|
$arg = strtoupper($arg);
|
||||||
if (($arg == 'TRUE') || ($arg == PHPExcel_Calculation::getTRUE())) {
|
if (($arg == 'TRUE') || ($arg == PHPExcel_Calculation::getTRUE())) {
|
||||||
$arg = true;
|
$arg = TRUE;
|
||||||
} elseif (($arg == 'FALSE') || ($arg == PHPExcel_Calculation::getFALSE())) {
|
} elseif (($arg == 'FALSE') || ($arg == PHPExcel_Calculation::getFALSE())) {
|
||||||
$arg = false;
|
$arg = FALSE;
|
||||||
} else {
|
} else {
|
||||||
return PHPExcel_Calculation_Functions::VALUE();
|
return PHPExcel_Calculation_Functions::VALUE();
|
||||||
}
|
}
|
||||||
$returnValue = $returnValue && ($arg != 0);
|
$returnValue = $returnValue && ($arg != 0);
|
||||||
}
|
}
|
||||||
++$argCount;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return
|
// Return
|
||||||
if ($argCount == 0) {
|
if ($argCount < 0) {
|
||||||
return PHPExcel_Calculation_Functions::VALUE();
|
return PHPExcel_Calculation_Functions::VALUE();
|
||||||
}
|
}
|
||||||
return $returnValue;
|
return $returnValue;
|
||||||
@ -158,12 +157,12 @@ class PHPExcel_Calculation_Logical {
|
|||||||
*/
|
*/
|
||||||
public static function LOGICAL_OR() {
|
public static function LOGICAL_OR() {
|
||||||
// Return value
|
// Return value
|
||||||
$returnValue = False;
|
$returnValue = FALSE;
|
||||||
|
|
||||||
// Loop through the arguments
|
// Loop through the arguments
|
||||||
$aArgs = PHPExcel_Calculation_Functions::flattenArray(func_get_args());
|
$aArgs = PHPExcel_Calculation_Functions::flattenArray(func_get_args());
|
||||||
$argCount = 0;
|
$argCount = -1;
|
||||||
foreach ($aArgs as $arg) {
|
foreach ($aArgs as $argCount => $arg) {
|
||||||
// Is it a boolean value?
|
// Is it a boolean value?
|
||||||
if (is_bool($arg)) {
|
if (is_bool($arg)) {
|
||||||
$returnValue = $returnValue || $arg;
|
$returnValue = $returnValue || $arg;
|
||||||
@ -172,19 +171,18 @@ class PHPExcel_Calculation_Logical {
|
|||||||
} elseif (is_string($arg)) {
|
} elseif (is_string($arg)) {
|
||||||
$arg = strtoupper($arg);
|
$arg = strtoupper($arg);
|
||||||
if (($arg == 'TRUE') || ($arg == PHPExcel_Calculation::getTRUE())) {
|
if (($arg == 'TRUE') || ($arg == PHPExcel_Calculation::getTRUE())) {
|
||||||
$arg = true;
|
$arg = TRUE;
|
||||||
} elseif (($arg == 'FALSE') || ($arg == PHPExcel_Calculation::getFALSE())) {
|
} elseif (($arg == 'FALSE') || ($arg == PHPExcel_Calculation::getFALSE())) {
|
||||||
$arg = false;
|
$arg = FALSE;
|
||||||
} else {
|
} else {
|
||||||
return PHPExcel_Calculation_Functions::VALUE();
|
return PHPExcel_Calculation_Functions::VALUE();
|
||||||
}
|
}
|
||||||
$returnValue = $returnValue || ($arg != 0);
|
$returnValue = $returnValue || ($arg != 0);
|
||||||
}
|
}
|
||||||
++$argCount;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return
|
// Return
|
||||||
if ($argCount == 0) {
|
if ($argCount < 0) {
|
||||||
return PHPExcel_Calculation_Functions::VALUE();
|
return PHPExcel_Calculation_Functions::VALUE();
|
||||||
}
|
}
|
||||||
return $returnValue;
|
return $returnValue;
|
||||||
@ -211,14 +209,14 @@ class PHPExcel_Calculation_Logical {
|
|||||||
* @param mixed $logical A value or expression that can be evaluated to TRUE or FALSE
|
* @param mixed $logical A value or expression that can be evaluated to TRUE or FALSE
|
||||||
* @return boolean The boolean inverse of the argument.
|
* @return boolean The boolean inverse of the argument.
|
||||||
*/
|
*/
|
||||||
public static function NOT($logical) {
|
public static function NOT($logical=FALSE) {
|
||||||
$logical = PHPExcel_Calculation_Functions::flattenSingleValue($logical);
|
$logical = PHPExcel_Calculation_Functions::flattenSingleValue($logical);
|
||||||
if (is_string($logical)) {
|
if (is_string($logical)) {
|
||||||
$logical = strtoupper($logical);
|
$logical = strtoupper($logical);
|
||||||
if (($logical == 'TRUE') || ($logical == PHPExcel_Calculation::getTRUE())) {
|
if (($logical == 'TRUE') || ($logical == PHPExcel_Calculation::getTRUE())) {
|
||||||
return false;
|
return FALSE;
|
||||||
} elseif (($logical == 'FALSE') || ($logical == PHPExcel_Calculation::getFALSE())) {
|
} elseif (($logical == 'FALSE') || ($logical == PHPExcel_Calculation::getFALSE())) {
|
||||||
return true;
|
return TRUE;
|
||||||
} else {
|
} else {
|
||||||
return PHPExcel_Calculation_Functions::VALUE();
|
return PHPExcel_Calculation_Functions::VALUE();
|
||||||
}
|
}
|
||||||
@ -259,12 +257,12 @@ class PHPExcel_Calculation_Logical {
|
|||||||
* @param mixed $returnIfFalse Optional value to return when condition is false
|
* @param mixed $returnIfFalse Optional value to return when condition is false
|
||||||
* @return mixed The value of returnIfTrue or returnIfFalse determined by condition
|
* @return mixed The value of returnIfTrue or returnIfFalse determined by condition
|
||||||
*/
|
*/
|
||||||
public static function STATEMENT_IF($condition = true, $returnIfTrue = 0, $returnIfFalse = False) {
|
public static function STATEMENT_IF($condition = TRUE, $returnIfTrue = 0, $returnIfFalse = FALSE) {
|
||||||
$condition = (is_null($condition)) ? True : (boolean) PHPExcel_Calculation_Functions::flattenSingleValue($condition);
|
$condition = (is_null($condition)) ? TRUE : (boolean) PHPExcel_Calculation_Functions::flattenSingleValue($condition);
|
||||||
$returnIfTrue = (is_null($returnIfTrue)) ? 0 : PHPExcel_Calculation_Functions::flattenSingleValue($returnIfTrue);
|
$returnIfTrue = (is_null($returnIfTrue)) ? 0 : PHPExcel_Calculation_Functions::flattenSingleValue($returnIfTrue);
|
||||||
$returnIfFalse = (is_null($returnIfFalse)) ? False : PHPExcel_Calculation_Functions::flattenSingleValue($returnIfFalse);
|
$returnIfFalse = (is_null($returnIfFalse)) ? FALSE : PHPExcel_Calculation_Functions::flattenSingleValue($returnIfFalse);
|
||||||
|
|
||||||
return ($condition ? $returnIfTrue : $returnIfFalse);
|
return ($condition) ? $returnIfTrue : $returnIfFalse;
|
||||||
} // function STATEMENT_IF()
|
} // function STATEMENT_IF()
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user