#172764 by pwolanin and chx: avoid using the expensive array_shift() in menu.inc

6.x
Gábor Hojtsy 2007-09-10 12:21:30 +00:00
parent 89bf1e1235
commit 8f9143ad0d
1 changed files with 6 additions and 4 deletions

View File

@ -1291,7 +1291,7 @@ function menu_set_active_trail($new_trail = NULL) {
} }
$tree = menu_tree_page_data(menu_get_active_menu_name()); $tree = menu_tree_page_data(menu_get_active_menu_name());
$curr = array_shift($tree); list($key, $curr) = each($tree);
while ($curr) { while ($curr) {
// Terminate the loop when we find the current path in the active trail. // 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']; $trail[] = $curr['link'];
$tree = $curr['below']; $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), // 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])) { if (!isset($menu[$router_path])) {
list($ancestors) = menu_get_ancestors($parts); list($ancestors) = menu_get_ancestors($parts);
$ancestors[] = ''; $ancestors[] = '';
while ($ancestors && (empty($menu[$router_path]))) { foreach ($ancestors as $key => $router_path) {
$router_path = array_shift($ancestors); if (isset($menu[$router_path])) {
break;
}
} }
} }
return $router_path; return $router_path;