--- block.module.orig	2010-09-20 22:49:24.226666676 +0200
+++ block.module	2010-09-20 22:50:01.510000004 +0200
@@ -426,7 +426,7 @@
 function block_list($region) {
   global $user, $theme_key;
 
-  static $blocks = array();
+  static $blocks = array(), $cache_enabled = NULL, $do_throttle = NULL;
 
   if (!count($blocks)) {
     $rids = array_keys($user->roles);
@@ -480,6 +480,15 @@
     $blocks[$region] = array();
   }
 
+  // Performance fix, call module_implements() and module_invoke() only once
+  // is necessary.
+  if ($cache_enabled === NULL) {
+    $grant_modules = module_implements('node_grants');
+    $cache_enabled = empty($grant_modules);
+    unset($grant_modules);
+    $do_throttle = module_invoke('throttle', 'status') > 0;
+  }
+
   foreach ($blocks[$region] as $key => $block) {
     // Render the block content if it has not been created already.
     if (!isset($block->content)) {
@@ -488,11 +497,11 @@
       if ($block->enabled && $block->page_match) {
         // Check the current throttle status and see if block should be displayed
         // based on server load.
-        if (!($block->throttle && (module_invoke('throttle', 'status') > 0))) {
+        if (!($block->throttle && $do_throttle)) {
           // Try fetching the block from cache. Block caching is not compatible with
           // node_access modules. We also preserve the submission of forms in blocks,
           // by fetching from cache only if the request method is 'GET'.
-          if (!count(module_implements('node_grants')) && $_SERVER['REQUEST_METHOD'] == 'GET' && ($cid = _block_get_cache_id($block)) && ($cache = cache_get($cid, 'cache_block'))) {
+          if ($cache_enabled && $_SERVER['REQUEST_METHOD'] == 'GET' && ($cid = _block_get_cache_id($block)) && ($cache = cache_get($cid, 'cache_block'))) {
             $array = $cache->data;
           }
           else {
