From b19a203595b69067b3665ee179fb4b58cf5a014c Mon Sep 17 00:00:00 2001 From: Ted Wood Date: Sat, 5 Jan 2013 16:02:43 -0800 Subject: utilize static function variables in Common::log_message() to "cache" log threshold and Log library instance to reduce function calls --- system/core/Common.php | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'system/core/Common.php') diff --git a/system/core/Common.php b/system/core/Common.php index a4b4f2b3e..d494caf80 100644 --- a/system/core/Common.php +++ b/system/core/Common.php @@ -413,14 +413,23 @@ if ( ! function_exists('log_message')) */ function log_message($level = 'error', $message, $php_error = FALSE) { - static $_log; + static $_log, $_log_threshold; + + if ($_log_threshold === NULL) + { + $_log_threshold = config_item('log_threshold'); + } - if (config_item('log_threshold') === 0) + if ($_log_threshold === 0) { return; } - $_log =& load_class('Log', 'core'); + if ($_log === NULL) + { + $_log =& load_class('Log', 'core'); + } + $_log->write_log($level, $message, $php_error); } } -- cgit v1.2.3-24-g4f1b