summaryrefslogtreecommitdiff
path: root/includes/menu.inc
diff options
context:
space:
mode:
authorGábor Hojtsy <gabor@hojtsy.hu>2007-09-10 12:21:30 +0000
committerGábor Hojtsy <gabor@hojtsy.hu>2007-09-10 12:21:30 +0000
commit8f9143ad0d5adf6fcfd4a77ae85645847035b868 (patch)
treeed4c4015774e11699d45b9fc81faec100a1dabde /includes/menu.inc
parent89bf1e12352be3d2a0be66c756ef6b855fd6744a (diff)
downloadbrdo-8f9143ad0d5adf6fcfd4a77ae85645847035b868.tar.gz
brdo-8f9143ad0d5adf6fcfd4a77ae85645847035b868.tar.bz2
#172764 by pwolanin and chx: avoid using the expensive array_shift() in menu.inc
Diffstat (limited to 'includes/menu.inc')
-rw-r--r--includes/menu.inc10
1 files changed, 6 insertions, 4 deletions
diff --git a/includes/menu.inc b/includes/menu.inc
index a7aa04297..d18490e88 100644
--- a/includes/menu.inc
+++ b/includes/menu.inc
@@ -1291,7 +1291,7 @@ function menu_set_active_trail($new_trail = NULL) {
}
$tree = menu_tree_page_data(menu_get_active_menu_name());
- $curr = array_shift($tree);
+ list($key, $curr) = each($tree);
while ($curr) {
// Terminate the loop when we find the current path in the active trail.
@@ -1305,7 +1305,7 @@ function menu_set_active_trail($new_trail = NULL) {
$trail[] = $curr['link'];
$tree = $curr['below'];
}
- $curr = array_shift($tree);
+ list($key, $curr) = each($tree);
}
}
// Make sure the current page is in the trail (needed for the page title),
@@ -1709,8 +1709,10 @@ function _menu_find_router_path($menu, $link_path) {
if (!isset($menu[$router_path])) {
list($ancestors) = menu_get_ancestors($parts);
$ancestors[] = '';
- while ($ancestors && (empty($menu[$router_path]))) {
- $router_path = array_shift($ancestors);
+ foreach ($ancestors as $key => $router_path) {
+ if (isset($menu[$router_path])) {
+ break;
+ }
}
}
return $router_path;