From f1b75374b2e087145cab5348331596ce3c16e8f6 Mon Sep 17 00:00:00 2001
From: alecpl <alec@alec.pl>
Date: Thu, 08 May 2008 03:38:36 -0400
Subject: [PATCH] - Optimized messages sorting on servers without sort capability (#1485049)

---
 CHANGELOG                      |    1 +
 program/include/rcube_imap.php |   11 +++--------
 2 files changed, 4 insertions(+), 8 deletions(-)

diff --git a/CHANGELOG b/CHANGELOG
index e4e79ad..e67b925 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -4,6 +4,7 @@
 2008/05/08 (alec)
 ----------
 - Don't attempt to delete cache entries if enable_caching is FALSE (#1485051)
+- Optimized messages sorting on servers without sort capability (#1485049)
 
 2008/05/07 (davidke/richs)
 ----------
diff --git a/program/include/rcube_imap.php b/program/include/rcube_imap.php
index a01687d..2716934 100644
--- a/program/include/rcube_imap.php
+++ b/program/include/rcube_imap.php
@@ -602,7 +602,6 @@
 
       }
 
-
     // return empty array if no messages found
     if (!is_array($a_msg_headers) || empty($a_msg_headers)) {
       return array();
@@ -2837,13 +2836,9 @@
     */
    function position_of($seqnum)
    {
-      $c = count($this->sequence_numbers);
-      for ($pos = 0; $pos <= $c; $pos++)
-      {
-         if ($this->sequence_numbers[$pos] == $seqnum)
-            return $pos;
-      }
-      return -1;
+      $pos = array_search($seqnum, $this->sequence_numbers);
+      if ($pos === false) return -1;
+      return $pos;
    }
  
    /**

--
Gitblit v1.9.1