Commit 8e19d799 authored by Dries's avatar Dries

- Patch #619902 by sun: performance improvement: dashboard, region and block...

- Patch #619902 by sun: performance improvement: dashboard, region and block building had unnecessary function calls.
parent 5cc6df56
......@@ -2200,7 +2200,7 @@ function form_process_container($element, &$form_state) {
* @param $element
* An associative array containing the properties and children of the
* group.
* Properties used: #children.
* Properties used: #id, #attributes, #children.
* @return
* A themed HTML string representing the form element.
*
......@@ -2208,7 +2208,12 @@ function form_process_container($element, &$form_state) {
*/
function theme_container($variables) {
$element = $variables['element'];
return '<div class="form-wrapper" id="' . $element['#id'] . '">' . $element['#children'] . '</div>';
if (!isset($element['#attributes']['id'])) {
$element['#attributes']['id'] = drupal_html_id($element['#id']);
}
// Force the 'form-wrapper' class.
$element['#attributes']['class'][] = 'form-wrapper';
return '<div' . drupal_attributes($element['#attributes']) . '>' . $element['#children'] . '</div>';
}
/**
......
......@@ -574,18 +574,19 @@ function block_theme_initialize($theme) {
* array key instead of <i>module</i>_<i>delta</i>.
*/
function block_list($region) {
$blocks = &drupal_static(__FUNCTION__, array());
$blocks = &drupal_static(__FUNCTION__);
if (empty($blocks)) {
if (!isset($blocks)) {
$blocks = _block_load_blocks();
}
// Create an empty array if there were no entries.
// Create an empty array if there are no entries.
if (!isset($blocks[$region])) {
$blocks[$region] = array();
}
$blocks[$region] = _block_render_blocks($blocks[$region]);
else {
$blocks[$region] = _block_render_blocks($blocks[$region]);
}
return $blocks[$region];
}
......
......@@ -208,8 +208,12 @@ function dashboard_admin($launch_customize = FALSE) {
* Returns TRUE if the user is currently viewing the dashboard.
*/
function dashboard_is_visible() {
$menu_item = menu_get_item();
return isset($menu_item['page_callback']) && $menu_item['page_callback'] == 'dashboard_admin';
static $is_visible;
if (!isset($is_visible)) {
$menu_item = menu_get_item();
$is_visible = isset($menu_item['page_callback']) && $menu_item['page_callback'] == 'dashboard_admin';
}
return $is_visible;
}
/**
......@@ -225,7 +229,11 @@ function dashboard_region_descriptions() {
* Return an array of dashboard region names.
*/
function dashboard_regions() {
return array_keys(dashboard_region_descriptions());
static $regions;
if (!isset($regions)) {
$regions = array_keys(dashboard_region_descriptions());
}
return $regions;
}
/**
......@@ -233,7 +241,7 @@ function dashboard_regions() {
*/
function dashboard_dashboard_regions() {
return array(
'dashboard_main' => 'Dashboard main',
'dashboard_main' => 'Dashboard main',
'dashboard_sidebar' => 'Dashboard sidebar',
);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment