]> git.mxchange.org Git - hub.git/commitdiff
"Cached" method names to skip some expensive code, re-enabled debug line.
authorRoland Haeder <roland@mxchange.org>
Sat, 15 Feb 2014 23:45:56 +0000 (00:45 +0100)
committerRoland Haeder <roland@mxchange.org>
Sat, 15 Feb 2014 23:45:56 +0000 (00:45 +0100)
Signed-off-by: Roland Haeder <roland@mxchange.org>
application/hub/main/package/assembler/class_PackageAssembler.php

index ba8cf837b31f932f2fc891f88eaff2a327f45b6c..9197199c5aac42360b1c5c70e5b26bb5721a98ef 100644 (file)
@@ -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))) {