From: Michael M Slusarz Date: Tue, 24 Mar 2009 20:39:09 +0000 (-0600) Subject: Optimize Horde_Imap_Client_Thread for storage X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=2750429a1ccae72b9a196301d8d43697401f18ed;p=horde.git Optimize Horde_Imap_Client_Thread for storage Now that it may be serialized and stored in cache, optimize the internal data structures. New storage saves approx. 60%. --- diff --git a/framework/Imap_Client/lib/Horde/Imap/Client/Base.php b/framework/Imap_Client/lib/Horde/Imap/Client/Base.php index db88b5d6e..e5907dfe4 100644 --- a/framework/Imap_Client/lib/Horde/Imap/Client/Base.php +++ b/framework/Imap_Client/lib/Horde/Imap/Client/Base.php @@ -1473,11 +1473,15 @@ abstract class Horde_Imap_Client_Base * message sequence number (if 'sequence' is true). Values * of each entry: *
-     * 'base' - (integer) The UID of the base message. Is null if this is the
-     *          only message in the thread.
-     * 'last' - (boolean) Is this the last message in a subthread?
-     * 'level' - (integer) The thread level of this message (1 = base).
-     * 'uid' - (integer) The UID of the message.
+     * 'b' (base) - (integer) [OPTIONAL] The ID of the base message. Is not
+     *              set, this is the only message in the thread.
+     *              DEFAULT: Only message in thread
+     * 'l' (level) - (integer) [OPTIONAL] The thread level of this
+     *               message (1 = base).
+     *               DEFAULT: 0
+     * 's' (subthread) - (boolean) [OPTIONAL] Are there more messages in this
+     *                   subthread?
+     *                   DEFAULT: No
      * 
* @throws Horde_Imap_Client_Exception */ diff --git a/framework/Imap_Client/lib/Horde/Imap/Client/Socket.php b/framework/Imap_Client/lib/Horde/Imap/Client/Socket.php index 821fb3b69..98584acbf 100644 --- a/framework/Imap_Client/lib/Horde/Imap/Client/Socket.php +++ b/framework/Imap_Client/lib/Horde/Imap/Client/Socket.php @@ -1962,12 +1962,21 @@ class Horde_Imap_Client_Socket extends Horde_Imap_Client_Base if (is_null($tp['base']) && ($level || $cnt)) { $tp['base'] = $val; } - $tp['resp'][$val] = array( - 'base' => $tp['base'], - 'last' => $islast, - 'level' => $level++, - 'id' => $val - ); + + $tp['resp'][$val] = array(); + $ptr = &$tp['resp'][$val]; + + if (!is_null($tp['base'])) { + $ptr['b'] = $tp['base']; + } + + if (!$islast) { + $ptr['s'] = true; + } + + if ($level++) { + $ptr['l'] = $level; + } } $islast = true; } diff --git a/framework/Imap_Client/lib/Horde/Imap/Client/Thread.php b/framework/Imap_Client/lib/Horde/Imap/Client/Thread.php index a5cc413a7..e5269f799 100644 --- a/framework/Imap_Client/lib/Horde/Imap/Client/Thread.php +++ b/framework/Imap_Client/lib/Horde/Imap/Client/Thread.php @@ -61,8 +61,8 @@ class Horde_Imap_Client_Thread */ public function getThreadIndent($index) { - return isset($this->_thread[$index]['level']) - ? $this->_thread[$index]['level'] + return isset($this->_thread[$index]) + ? (isset($this->_thread[$index]['l']) ? $this->_thread[$index]['l'] : 0) : false; } @@ -76,8 +76,8 @@ class Horde_Imap_Client_Thread */ public function getThreadBase($index) { - return !empty($this->_thread[$index]['base']) - ? $this->_thread[$index]['base'] + return isset($this->_thread[$index]) + ? (isset($this->_thread[$index]['b']) ? $this->_thread[$index]['b'] : null) : false; } @@ -92,9 +92,7 @@ class Horde_Imap_Client_Thread */ public function lastInLevel($index) { - return !empty($this->_thread[$index]['last']) - ? $this->_thread[$index]['last'] - : false; + return empty($this->_thread[$index]['s']); } /** @@ -131,7 +129,7 @@ class Horde_Imap_Client_Thread while (list($k, $v) = each($this->_thread)) { if ($k == $begin) { $in_thread = true; - } elseif ($in_thread && ($v['base'] != $begin)) { + } elseif ($in_thread && ($this->getThreadBase($k) != $begin)) { break; }