From: Roland Häder Date: Sun, 12 Dec 2021 07:44:25 +0000 (+0100) Subject: Continued: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=b580ca852dc945d23290a6f7fb2c77e7c52e0d4b;p=core.git Continued: - "cached" configuration entry 'developer_mode_enabled' and 'debug_*_output_timings' into class fields to avoid "expensive" calls all over again to FrameworkConfiguration->getConfigEntry() Signed-off-by: Roland Häder --- diff --git a/framework/loader/class_ClassLoader.php b/framework/loader/class_ClassLoader.php index 247975fa..8ce8488a 100644 --- a/framework/loader/class_ClassLoader.php +++ b/framework/loader/class_ClassLoader.php @@ -66,6 +66,11 @@ final class ClassLoader { */ private static $selfInstance = NULL; + /** + * Cached configuration entry 'developer_mode_enabled' + */ + private static $developerModeEnabled = false; + /** * Array with all valid but pending for loading file names (class, * interfaces, traits must start with below prefix). @@ -152,7 +157,8 @@ final class ClassLoader { * @return void */ private function __construct () { - // This is empty for now + // Cache config entry + self::$developerModeEnabled = FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('developer_mode_enabled'); } /** @@ -162,7 +168,7 @@ final class ClassLoader { */ public function __destruct () { // Skip here if dev-mode - if (FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('developer_mode_enabled')) { + if (self::$developerModeEnabled) { return; } @@ -504,7 +510,7 @@ final class ClassLoader { */ private function initClassLoader () { // Construct the FQFN for the cache - if (!FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('developer_mode_enabled')) { + if (!self::$developerModeEnabled) { // Init cache instances $this->listCacheFile = new SplFileInfo(FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('local_database_path') . 'list-' . FrameworkBootstrap::getDetectedApplicationName() . '.cache'); $this->classCacheFile = new SplFileInfo(FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('local_database_path') . 'class-' . FrameworkBootstrap::getDetectedApplicationName() . '.cache'); @@ -518,7 +524,7 @@ final class ClassLoader { self::$selfInstance = $this; // Skip here if no dev-mode - if (FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('developer_mode_enabled')) { + if (self::$developerModeEnabled) { return; } @@ -580,7 +586,7 @@ final class ClassLoader { unset($this->pendingFiles[$fileName]); // Developer mode excludes caching (better debugging) - if (!FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('developer_mode_enabled')) { + if (!self::$developerModeEnabled) { // Reset cache //* NOISY-DEBUG: */ printf('[%s:%d] classesCached=false' . PHP_EOL, __METHOD__, __LINE__); $this->classesCached = false; diff --git a/framework/main/classes/output/debug/console/class_DebugConsoleOutput.php b/framework/main/classes/output/debug/console/class_DebugConsoleOutput.php index 80915da6..804119a5 100644 --- a/framework/main/classes/output/debug/console/class_DebugConsoleOutput.php +++ b/framework/main/classes/output/debug/console/class_DebugConsoleOutput.php @@ -33,14 +33,22 @@ use Org\Mxchange\CoreFramework\Stream\Output\OutputStreamer; * along with this program. If not, see . */ class DebugConsoleOutput extends BaseDebugOutput implements Debugger, OutputStreamer, Registerable { + /** + * Cached configuration entry 'debug_*_output_timings' + */ + private $debugOutputTimings = 'N'; + /** * Protected constructor * * @return void */ private function __construct () { - // Call parent constructor + // Call parent constructor first parent::__construct(__CLASS__); + + // Cache configuration entry + $this->debugOutputTimings = FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('debug_' . FrameworkBootstrap::getRequestTypeFromSystem() . '_output_timings'); } /** @@ -71,7 +79,7 @@ class DebugConsoleOutput extends BaseDebugOutput implements Debugger, OutputStre } // Are debug times enabled? - if (FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('debug_' . FrameworkBootstrap::getRequestTypeFromSystem() . '_output_timings') == 'Y') { + if ($this->debugOutputTimings == 'Y') { // Output it first $output = $this->getPrintableExecutionTime() . $output; }