From 97b1248c028b0c59ccd28a094dffa41720b29006 Mon Sep 17 00:00:00 2001 From: philippe_mingo Date: Sat, 23 Mar 2002 16:23:57 +0000 Subject: [PATCH] Optimization: readMailboxParent was only been used in imap_mailbox. Removed from strings.php as this is a frequent loaded module. git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@2624 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- functions/imap_mailbox.php | 21 +++++++++++++++++++++ functions/page_header.php | 1 - functions/strings.php | 33 +++++++++++---------------------- 3 files changed, 32 insertions(+), 23 deletions(-) diff --git a/functions/imap_mailbox.php b/functions/imap_mailbox.php index f98b0131..f6c8d42a 100755 --- a/functions/imap_mailbox.php +++ b/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; diff --git a/functions/page_header.php b/functions/page_header.php index 4e134c14..7910dd84 100644 --- a/functions/page_header.php +++ b/functions/page_header.php @@ -107,7 +107,6 @@ function displayPageHeader($color, $mailbox, $xtra='') { } - echo "\n\n"; /** Here is the header and wrapping table **/ $shortBoxName = readShortMailboxName($mailbox, $delimiter); diff --git a/functions/strings.php b/functions/strings.php index 7d17332d..0b146f00 100644 --- a/functions/strings.php +++ b/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(); -?> +?> \ No newline at end of file -- 2.25.1