From: Chuck Hagenbuch Date: Sat, 27 Nov 2010 04:24:49 +0000 (-0500) Subject: Fix some caching logic, and store information we get from dependency objects once... X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=f2a7094e85c8665d9f62caeaae46f719063c4570;p=horde.git Fix some caching logic, and store information we get from dependency objects once, rather than having to re-fetch it when a cached Log object is retrieved. --- diff --git a/framework/Vcs/lib/Horde/Vcs/Log.php b/framework/Vcs/lib/Horde/Vcs/Log.php index 139070166..7d3e4c077 100644 --- a/framework/Vcs/lib/Horde/Vcs/Log.php +++ b/framework/Vcs/lib/Horde/Vcs/Log.php @@ -1,6 +1,6 @@ _initialized) { + $this->_init(); + $this->_initialized = true; + } } /** @@ -98,7 +109,7 @@ abstract class Horde_Vcs_Log public function queryBranch() { $this->_ensureInitialized(); - return array(); + return $this->_branch; } /** @@ -129,17 +140,19 @@ abstract class Horde_Vcs_Log public function querySymbolicBranches() { $this->_ensureInitialized(); + return $this->_symbolicBranches; + } - $symBranches = array(); + protected function _setSymbolicBranches() + { + $this->_symbolicBranches = array(); $branches = $this->_file->queryBranches(); foreach ($this->_branches as $branch) { if (($key = array_search($branch, $branches)) !== false) { - $symBranches[$key] = $branch; + $this->_symbolicBranches[$key] = $branch; } } - - return $symBranches; } /** diff --git a/framework/Vcs/lib/Horde/Vcs/Log/Cvs.php b/framework/Vcs/lib/Horde/Vcs/Log/Cvs.php index 17aa8493f..2a96a1e08 100644 --- a/framework/Vcs/lib/Horde/Vcs/Log/Cvs.php +++ b/framework/Vcs/lib/Horde/Vcs/Log/Cvs.php @@ -20,11 +20,9 @@ class Horde_Vcs_Log_Cvs extends Horde_Vcs_Log */ protected $_branch; - private $_initialized; - protected function _init() { - $raw = $this->_file->getAccum(); + $raw = $this->_file->getAccum(); /* Initialise a simple state machine to parse the output of rlog */ $state = 'init'; @@ -77,14 +75,14 @@ class Horde_Vcs_Log_Cvs extends Horde_Vcs_Log /* Assume the rest of the lines are the log message */ $this->_log = implode("\n", $raw); $this->_tags = $this->_file->queryRevsym($this->_rev); - } - protected function _ensureInitialized() - { - if (!$this->_initialized) { - $this->_init(); - $this->_initialized = true; - } + $this->_setSymbolicBranches(); + + $branches = $this->_file->queryBranches(); + $key = array_keys($branches, $this->_rev); + $this->_branch = empty($key) + ? array_keys($branches, $this->_rep->strip($this->_rev, 1)) + : $key; } /** @@ -94,21 +92,4 @@ class Horde_Vcs_Log_Cvs extends Horde_Vcs_Log { $this->_branch = array($branch); } - - /** - * TODO - */ - public function queryBranch() - { - if (!empty($this->_branch)) { - return $this->_branch; - } - - $branches = $this->_file->queryBranches(); - $key = array_keys($branches, $this->_rev); - return empty($key) - ? array_keys($branches, $this->_rep->strip($this->_rev, 1)) - : $key; - } - } \ No newline at end of file diff --git a/framework/Vcs/lib/Horde/Vcs/Log/Git.php b/framework/Vcs/lib/Horde/Vcs/Log/Git.php index 64a478b01..41718c992 100644 --- a/framework/Vcs/lib/Horde/Vcs/Log/Git.php +++ b/framework/Vcs/lib/Horde/Vcs/Log/Git.php @@ -18,19 +18,6 @@ class Horde_Vcs_Log_Git extends Horde_Vcs_Log */ protected $_parent = null; - /** - * @var boolean - */ - private $_initialized; - - protected function _ensureInitialized() - { - if (!$this->_initialized) { - $this->_init(); - $this->_initialized = true; - } - } - protected function _init() { /* Get diff statistics. */ @@ -134,6 +121,9 @@ class Horde_Vcs_Log_Git extends Horde_Vcs_Log $line = next($lines); } + + $this->_setSymbolicBranches(); + $this->_branch = $this->_file->queryBranch($this->_rev); } /** @@ -148,17 +138,8 @@ class Horde_Vcs_Log_Git extends Horde_Vcs_Log /** * TODO */ - public function queryBranch() - { - return $this->_file->queryBranch($this->_rev); - } - - /** - * TODO - */ public function queryParent() { return $this->_parent; } - } \ No newline at end of file