[imp] Speedup patch

Alain Williams addw at phcomp.co.uk
Mon Nov 3 02:54:37 PST 2003


Please find a patch against imp-3.2.1 that should speed it up a bit.

The problem is in mailbox.php, the main loop that displays one line for every mail message
opened the file mailbox/message_summaries.inc for every message. The patch
creates the file mailbox/message_summaries_func.inc which defines a function that
does the same work. The result is that the file is opened/read/closed once rather than
20 odd times.

Please find attached a patch to mailbox.php and the file mailbox/message_summaries_func.inc.

-- 
Alain Williams

#include <std_disclaimer.h>

FATHERS-4-JUSTICE - Campaigning for equal rights for parents and the
best interests of our children. See http://www.fathers-4-justice.org
-------------- next part --------------
*** mailbox.php	2003-11-02 23:14:18.000000000 +0000
--- mailbox_old.php	2003-11-02 23:24:56.000000000 +0000
***************
*** 610,616 ****
  // Display message information.
  $curr_time = time();
  $curr_time -= ($curr_time % 60);
- include IMP_TEMPLATES . '/mailbox/message_summaries_func.inc';
  foreach ($mailboxOverview as $key => $message) {
      if ($imp['mailbox'] == '**search') {
          if (!isset($lastFolder) || ($message['folder'] != $lastFolder)) {
--- 610,615 ----
***************
*** 822,830 ****
          $from_link = $stylefrm;
      }
  
!     message_summaries($bg, $css, $h, $message, $status, $styledat, $from_link, 
!      ($attachment ? Horde::pimg($attachment . '.gif') : '&nbsp;'), Horde::link($target, $sub) . $stylesub, $msg_size);
! #    include IMP_TEMPLATES . '/mailbox/message_summaries.inc';
  }
  
  if ($end == 0) {
--- 821,827 ----
          $from_link = $stylefrm;
      }
  
!     include IMP_TEMPLATES . '/mailbox/message_summaries.inc';
  }
  
  if ($end == 0) {
-------------- next part --------------
<?php
function message_summaries($bg, $css, $h, $message, $status, $styledat, $from_link, $attachment, $link, $msg_size)
{
 global $imp;
 $msg_number = $h->msgno;

 echo "<tr class=\"$bg\" onmouseover=\"javascript:style.backgroundColor='" . $css['.' . $bg . '-hi']['background-color'] .
      "'\" onmouseout=\"javascript:style.backgroundColor='" . $css['.' . $bg]['background-color'] . "'\">\n";
 echo "  <td nowrap=\"nowrap\">\n";
 echo "   <input type=\"checkbox\" name=\"indices[]\" value=\"" . $h->uid;
           if ($imp['mailbox'] == '**search') echo ':' . $message['folder'];
     echo "\" />$status\n";
 echo " </td>\n";
 echo "  <td nowrap=\"nowrap\">$msg_number</td>\n";
 echo "  <td nowrap=\"nowrap\">$styledat</td>\n";
 echo "  <td nowrap=\"nowrap\">$from_link</td>\n";
 echo "  <td align=\"center\">"; echo $attachment ? Horde::pimg($attachment . '.gif') : '&nbsp;'; echo "</td>\n";
 echo "  <td>$link</a></td>\n";
 echo "  <td align=\"right\">$msg_size</td>\n";
 echo "</tr>\n";
}
?>


More information about the imp mailing list