From 9570db5eef5eaafd37110098d1c91427c9f2effe Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Thu, 16 Aug 2007 20:51:48 +0000 Subject: [PATCH] Removing the usage counter in from the template system * Template.php: (BSTemplate::cache): No longer initialize the usage counter (BSTemplate::fetch): Only increment the BSTemplate->uncached[] template counter when the template is not cached (BSTemplate::flsuh): Remove the template debug block and only show uncached templates and their usage --- Template.php | 44 ++++++++------------------------------------ 1 file changed, 8 insertions(+), 36 deletions(-) diff --git a/Template.php b/Template.php index 70d8f5a..8400c1a 100644 --- a/Template.php +++ b/Template.php @@ -82,12 +82,6 @@ class BSTemplate */ protected $cache = array(); - /** - * A list of the number of times each template has been used - * @var array - */ - protected $usage = array(); - /** * A list of templates that weren't cached, but are still used * @var array @@ -203,8 +197,7 @@ class BSTemplate $template = $this->_parseTemplate($this->_loadTemplate($name)); } - $this->cache["$name"] = $template; - $this->usage["$name"] = 0; + $this->cache[$name] = $template; } } } @@ -220,25 +213,18 @@ class BSTemplate */ public function fetch($name) { - if (isset($this->cache["$name"])) + if (isset($this->cache[$name])) { - $template = $this->cache["$name"]; + $template = $this->cache[$name]; } else { - $this->uncached[] = $name; + $this->uncached[$name]++; BSApp::Debug("Manually loading template '$name'"); $template = $this->_loadTemplate($name); $template = $this->_parseTemplate($template); } - if (!isset($this->usage["$name"])) - { - $this->usage["$name"] = 0; - } - - $this->usage["$name"]++; - return $template; } @@ -268,28 +254,14 @@ class BSTemplate $debugBlock .= "\n
Executed in " . round(BSFunctions::FetchMicrotimeDiff($_SERVER['REQUEST_TIME']), 10) . ' seconds
'; $debugBlock .= "\n
" . BSApp::GetDebugList() . "
"; - $optlist = array(); - $usage = array(); - foreach ($this->usage AS $name => $count) + if (sizeof($this->uncached) > 0) { - if (in_array($name, $this->uncached)) + foreach ($this->uncached AS $name => $count) { - $optlist[] = $name . '[' . $count . ']'; + $tpls[] = $name . "($count)"; } - $usage[] = $name . " ($count)"; - } - $sizeof = sizeof($this->uncached); - if ($sizeof > 0) - { - $debugBlock .= "
Uncached Template(s): $sizeof ( " . implode('   ', $optlist) . " )
\n"; - } - - $debugBlock .= (sizeof($this->uncached) < 1 ? "
\n" : '') . "
\n"; if (BSApp::GetType('Db')) { -- 2.43.5