Browse Source

Optimization:
readMailboxParent was only been used in imap_mailbox. Removed from
strings.php as this is a frequent loaded module.

philippe_mingo 23 years ago
parent
commit
05747bc945
3 changed files with 32 additions and 23 deletions
  1. 21 0
      functions/imap_mailbox.php
  2. 0 1
      functions/page_header.php
  3. 11 22
      functions/strings.php

+ 21 - 0
functions/imap_mailbox.php

@@ -13,6 +13,27 @@
 
 global $boxesnew;
 
+/**
+ * If $haystack is a full mailbox name, and $needle is the mailbox
+ * separator character, returns the second last part of the full
+ * mailbox name (i.e. the mailbox's parent mailbox)
+ */
+function readMailboxParent($haystack, $needle) {
+
+    if ($needle == '') {
+        $ret = '';
+    } else {
+        $parts = explode($needle, $haystack);
+        $elem = array_pop($parts);
+        while ($elem == '' && count($parts)) {
+            $elem = array_pop($parts);
+        }
+        $ret = join($needle, $parts);
+    }
+    return( $ret );
+}
+
+
 function isBoxBelow( $box2, $box1 ) {
     global $delimiter, $folder_prefix, $imap_server_type;
 

+ 0 - 1
functions/page_header.php

@@ -107,7 +107,6 @@ function displayPageHeader($color, $mailbox, $xtra='') {
 
     }
 
-
     echo "<BODY TEXT=\"$color[8]\" BGCOLOR=\"$color[4]\" LINK=\"$color[7]\" VLINK=\"$color[7]\" ALINK=\"$color[7]\" $onload>\n\n";
     /** Here is the header and wrapping table **/
     $shortBoxName = readShortMailboxName($mailbox, $delimiter);

+ 11 - 22
functions/strings.php

@@ -23,31 +23,20 @@ $version = '1.2.6 [cvs]';
  * separator character, returns the last part of the mailbox name.
  */
 function readShortMailboxName($haystack, $needle) {
+
     if ($needle == '') {
-        return $haystack;
-    }
-    $parts = explode($needle, $haystack);
-    $elem = array_pop($parts);
-    while ($elem == '' && count($parts)) {
-        $elem = array_pop($parts);
+        $elem = $haystack;
+    } else {
+	    $parts = explode($needle, $haystack);
+	    $elem = array_pop($parts);
+	    while ($elem == '' && count($parts)) {
+	        $elem = array_pop($parts);
+	    }
     }
-    return $elem;
+    return( $elem );
 }
 
-/**
- * If $haystack is a full mailbox name, and $needle is the mailbox
- * separator character, returns the second last part of the full
- * mailbox name (i.e. the mailbox's parent mailbox)
- */
-function readMailboxParent($haystack, $needle) {
-    if ($needle == '') return '';
-    $parts = explode($needle, $haystack);
-    $elem = array_pop($parts);
-    while ($elem == '' && count($parts)) {
-        $elem = array_pop($parts);
-    }
-    return join($needle, $parts);
-}
+
 
 /**
  * Returns the index of the first chunk of string $haystack that
@@ -596,4 +585,4 @@ function RemoveSlashes(&$array) {
 
 $PHP_SELF = php_self();
 
-?>
+?>