=== modified file 'includes/bootstrap.inc'
--- includes/bootstrap.inc	2009-11-02 03:46:43 +0000
+++ includes/bootstrap.inc	2009-11-05 07:30:24 +0000
@@ -2027,25 +2027,19 @@ function registry_rebuild() {
  *   Returns a variable by reference if $reset is FALSE.
  */
 function &drupal_static($name, $default_value = NULL, $reset = FALSE) {
-  static $data = array();
-
-  // Reset a single value, or all values.
-  if ($reset) {
-    if (isset($name)) {
-      unset($data[$name]);
-    }
-    else {
-      $data = array();
-    }
-    // We must return a reference to a variable.
-    $dummy = NULL;
-    return $dummy;
+  static $data = array(), $default = array();
+  if (!isset($name)) {
+    $data = $default;
+    return;
   }
-
-  if (!isset($data[$name])) {
-    $data[$name] = $default_value;
+  // We need to care for stored NULLs but array_key_exists is a bit slow.
+  $new_data = !$reset && !isset($data[$name]) && !array_key_exists($name, $data);
+  if ($new_data) {
+    $default[$name] = $default_value;
+  }
+  if ($new_data || $reset) {
+    $data[$name] = $default[$name];
   }
-
   return $data[$name];
 }
 

