Index: modules/toolbar/toolbar.module =================================================================== RCS file: /cvs/drupal/drupal/modules/toolbar/toolbar.module,v retrieving revision 1.6 diff -u -p -r1.6 toolbar.module --- modules/toolbar/toolbar.module 22 Aug 2009 14:34:22 -0000 1.6 +++ modules/toolbar/toolbar.module 24 Aug 2009 10:51:00 -0000 @@ -58,6 +58,17 @@ function toolbar_preprocess_page(&$vars) function toolbar_build() { global $user; + // Due to system_admin_menu_block_access(), building the toolbar links is + // expensive to render on each page, so we cache this information per-user. + // It is not possible to cache per role or combination of roles since + // access callbacks may use any arbitrary criteria not related to permissions + // to determine the visibility of menu links, however since the toolbar is + // likely to be accessible to a limited number of users, and is rendered on + // every page, it should still be more efficient than building it each time. + if ($cached = cache_get('toolbar:user:' . $GLOBALS['user']->uid, 'cache_block')) { + return $cached->data; + } + $module_path = drupal_get_path('module', 'toolbar'); $build = array( '#theme' => 'toolbar', @@ -104,6 +115,8 @@ function toolbar_build() { '#attributes' => array('id' => 'toolbar-shortcuts'), ); + cache_set('toolbar:user:' . $GLOBALS['user']->uid, $build, 'cache_block'); + return $build; }