From: Roland Haeder Date: Sat, 15 Feb 2014 23:45:56 +0000 (+0100) Subject: "Cached" method names to skip some expensive code, re-enabled debug line. X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=6da693b0db008ecf92ef18ba721f7bd6a605a7c3;p=hub.git "Cached" method names to skip some expensive code, re-enabled debug line. Signed-off-by: Roland Haeder --- diff --git a/application/hub/main/package/assembler/class_PackageAssembler.php b/application/hub/main/package/assembler/class_PackageAssembler.php index ba8cf837b..9197199c5 100644 --- a/application/hub/main/package/assembler/class_PackageAssembler.php +++ b/application/hub/main/package/assembler/class_PackageAssembler.php @@ -28,6 +28,11 @@ class PackageAssembler extends BaseHubSystem implements Assembler, Registerable */ private $pendingData = ''; + /** + * Private call-back methods + */ + private $callbacks = array(); + /** * Protected constructor * @@ -113,16 +118,16 @@ class PackageAssembler extends BaseHubSystem implements Assembler, Registerable ); // Construct call-back name from package error code - $methodName = 'handlePackageBy' . $this->convertToClassName($packageContent[BaseRawDataHandler::PACKAGE_ERROR_CODE]); + $this->callbacks[$packageContent[BaseRawDataHandler::PACKAGE_ERROR_CODE]] = 'handlePackageBy' . $this->convertToClassName($packageContent[BaseRawDataHandler::PACKAGE_ERROR_CODE]); // Abort if the call-back method is not there - if (!method_exists($this, $methodName)) { + if (!method_exists($this, $this->callbacks[$packageContent[BaseRawDataHandler::PACKAGE_ERROR_CODE]])) { // Throw an exception - throw new UnsupportedPackageCodeHandlerException(array($this, $methodName, $packageContent), BaseListener::EXCEPTION_UNSUPPORTED_PACKAGE_CODE_HANDLER); + throw new UnsupportedPackageCodeHandlerException(array($this, $this->callbacks[$packageContent[BaseRawDataHandler::PACKAGE_ERROR_CODE]], $packageContent), BaseListener::EXCEPTION_UNSUPPORTED_PACKAGE_CODE_HANDLER); } // END - if // Call it back - call_user_func(array($this, $methodName), $packageContent); + call_user_func(array($this, $this->callbacks[$packageContent[BaseRawDataHandler::PACKAGE_ERROR_CODE]]), $packageContent); } /************************************************************************** @@ -140,7 +145,7 @@ class PackageAssembler extends BaseHubSystem implements Assembler, Registerable */ private function handlePackageByUnhandledPackage (array $packageContent) { // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('PACKAGE-ASSEMBLER: packageData[' . BaseRawDataHandler::PACKAGE_RAW_DATA . ']=' . $packageContent[BaseRawDataHandler::PACKAGE_RAW_DATA]); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('PACKAGE-ASSEMBLER: packageData[' . BaseRawDataHandler::PACKAGE_RAW_DATA . ']=' . $packageContent[BaseRawDataHandler::PACKAGE_RAW_DATA]); // Check for some conditions if ((!$this->ifInputBufferIsEmpty()) || (!$this->isPackageContentCompleted($packageContent))) {