[Hastymail-cvs] hastymail/lib imap.php,1.177,1.178
Brought to you by:
sailfrog,
slushpupie
From: <sai...@us...> - 2003-05-27 21:43:57
|
Update of /cvsroot/hastymail/hastymail/lib In directory sc8-pr-cvs1:/tmp/cvs-serv21763 Modified Files: imap.php Log Message: some clean up to the server-side sorting function, trying to get some increased performance out of large folders, not much luck however. currently my largest folder (~21,000) takes about 3 seconds to sort by arrival. Not sure I can squeeze anything better out of that :) Index: imap.php =================================================================== RCS file: /cvsroot/hastymail/hastymail/lib/imap.php,v retrieving revision 1.177 retrieving revision 1.178 diff -u -d -r1.177 -r1.178 --- imap.php 26 May 2003 05:57:00 -0000 1.177 +++ imap.php 27 May 2003 21:43:53 -0000 1.178 @@ -358,50 +358,33 @@ $command = "A0004 UID SORT ($sort) US-ASCII ALL\r\n"; } fputs($imap_stream, $command); - $result[0] = fgets($imap_stream, 4096); - while (stristr($result[0], '[PARSE]')) { - $result[0] = fgets($imap_stream, 4096); - } - $n = 1; - while (!strstr($result[$n-1], 'A0004')) { - $result[$n]= fgets($imap_stream, 4096); + $n = -1; + do { + $n++; + $result[$n] = fgets($imap_stream, 4096); while (!strpos($result[$n], "\n", (strlen($result[$n])-1))) { $result[$n] .= fgets($imap_stream, 4096); + if (stristr($result[0], '[PARSE]')) { + $n--; + } } - if (stristr($result[$n], '* OK [PARSE]')) { - array_pop($result); - $n--; - } - $n++; + } while (substr($result[$n], 0, 5) != 'A0004'); + hm_check_errors($result[$n], 'A0004 OK', $command); + if ($n >= 3) { + array_pop($result); + $result = implode('', $result); } - hm_check_errors($result[$n-1], 'A0004 OK', $command); - if (isset($result[2]) && strstr($result[2], 'A0004')) { - $result[0] .= $result[1]; + else { + $result = $result[0]; } - if (trim($result[0]) == '* SORT' || trim($result[0]) == '* THREAD') { + if (trim($result) == '* SORT' || trim($result) == '* THREAD') { $result = ''; $_SESSION['sort_data'][$mailbox] = $result; return $result; } else { if (substr($sort_type, 0, 6) == 'THREAD') { - if ($quick) { - $temp = hm_parse_toplevel($result[0], true, 0); - unset($temp[0][0]); - unset($temp[0][1]); - $string = ''; - $temp = array_reverse($temp); - foreach ($temp as $index => $array) { - $string .= implode(' ', $array); - } - unset($temp); - $string = trim(str_replace(array('( ', ') ', ' (', ' )'), - array('(', ')', '(', ')'), - $string)); - } - else { - $string = trim(str_replace(' (', '(', substr($result[0], 9))); - } + $string = trim(str_replace(' (', '(', substr($result, 9))); $len = strlen($string); $uids = array(); $thread = array(); @@ -459,7 +442,7 @@ $sorted_array = array_reverse($uids); } else { - $sorted_array = preg_split('/ /', $result[0]); + $sorted_array = preg_split('/ /', $result); array_shift($sorted_array); array_shift($sorted_array); } |