diff options
author | Dries Buytaert <dries@buytaert.net> | 2009-11-11 08:52:53 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2009-11-11 08:52:53 +0000 |
commit | 8e19d799f6bc5b668f8a241464d2e544611d079f (patch) | |
tree | 8f1f249f23d65c871e37287a7f6e9ea635cb0434 | |
parent | 5cc6df569f7a802d6226a0bec6743a45544ac431 (diff) | |
download | brdo-8e19d799f6bc5b668f8a241464d2e544611d079f.tar.gz brdo-8e19d799f6bc5b668f8a241464d2e544611d079f.tar.bz2 |
- Patch #619902 by sun: performance improvement: dashboard, region and block building had unnecessary function calls.
-rw-r--r-- | includes/form.inc | 9 | ||||
-rw-r--r-- | modules/block/block.module | 11 | ||||
-rw-r--r-- | modules/dashboard/dashboard.module | 16 |
3 files changed, 25 insertions, 11 deletions
diff --git a/includes/form.inc b/includes/form.inc index 7ddd6125d..daf164368 100644 --- a/includes/form.inc +++ b/includes/form.inc @@ -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>'; } /** diff --git a/modules/block/block.module b/modules/block/block.module index 306870b99..374ffdd84 100644 --- a/modules/block/block.module +++ b/modules/block/block.module @@ -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]; } diff --git a/modules/dashboard/dashboard.module b/modules/dashboard/dashboard.module index c04c815bc..e7091fe4d 100644 --- a/modules/dashboard/dashboard.module +++ b/modules/dashboard/dashboard.module @@ -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', ); } |