Index: includes/common.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/common.inc,v
retrieving revision 1.953
diff -u -r1.953 common.inc
--- includes/common.inc	4 Aug 2009 06:38:56 -0000	1.953
+++ includes/common.inc	4 Aug 2009 14:35:34 -0000
@@ -1900,47 +1900,61 @@
  *   A translated date string in the requested format.
  */
 function format_date($timestamp, $type = 'medium', $format = '', $timezone = NULL, $langcode = NULL) {
-  $timezones = &drupal_static(__FUNCTION__, array());
+  $cache = &drupal_static(__FUNCTION__, array());
+
+  // Maintain a local cache of date variables to avoid repeated calls to
+  // variable_get().
+  if (!isset($cache['variables'])){
+    $cache['variables'] = array(
+      'small' => variable_get('date_format_short', 'm/d/Y - H:i'),
+      'medium' => variable_get('date_format_medium', 'D, m/d/Y - H:i'),
+      'large' => variable_get('date_format_long', 'l, F j, Y - H:i'),
+      'configurable_timezones' => variable_get('configurable_timezones', 1),
+      'date_default_timezone' => variable_get('date_default_timezone', 'UTC')
+    );
+  }
+
   if (!isset($timezone)) {
     global $user;
     if (variable_get('configurable_timezones', 1) && $user->uid && $user->timezone) {
       $timezone = $user->timezone;
     }
     else {
-      $timezone = variable_get('date_default_timezone', 'UTC');
+      $timezone = $cache['variables']['date_default_timezone'];
     }
   }
   // Store DateTimeZone objects in an array rather than repeatedly
   // contructing identical objects over the life of a request.
-  if (!isset($timezones[$timezone])) {
-    $timezones[$timezone] = timezone_open($timezone);
+  if (!isset($cache['timezones'][$timezone])) {
+    $cache['timezones'][$timezone] = timezone_open($timezone);
   }
 
   // Use the default langcode if none is set.
-  global $language;
   if (empty($langcode)) {
+    global $language;
     $langcode = isset($language->language) ? $language->language : 'en';
   }
 
   switch ($type) {
     case 'small':
-      $format = variable_get('date_format_short', 'm/d/Y - H:i');
+      $format = $cache['variables']['small'];
       break;
     case 'large':
-      $format = variable_get('date_format_long', 'l, F j, Y - H:i');
+      $format = $cache['variables']['large'];
       break;
     case 'custom':
       // No change to format.
       break;
     case 'medium':
     default:
-      $format = variable_get('date_format_medium', 'D, m/d/Y - H:i');
+      $format = $cache['variables']['medium'];
+      break;
   }
 
   // Create a DateTime object from the timestamp.
   $date_time = date_create('@' . $timestamp);
   // Set the time zone for the DateTime object.
-  date_timezone_set($date_time, $timezones[$timezone]);
+  date_timezone_set($date_time, $cache['timezones'][$timezone]);
 
   // Encode markers that should be translated. 'A' becomes '\xEF\AA\xFF'.
   // xEF and xFF are invalid UTF-8 sequences, and we assume they are not in the
Index: modules/node/node.test
===================================================================
RCS file: /cvs/drupal/drupal/modules/node/node.test,v
retrieving revision 1.38
diff -u -r1.38 node.test
--- modules/node/node.test	28 Jul 2009 19:18:06 -0000	1.38
+++ modules/node/node.test	4 Aug 2009 14:35:34 -0000
@@ -96,6 +96,8 @@
   function setUp() {
     parent::setUp();
 
+    drupal_static_reset('format_date');
+
     // Create and login user.
     $web_user = $this->drupalCreateUser(array('view revisions', 'revert revisions', 'edit any page content',
                                                'delete revisions', 'delete any page content'));
@@ -483,6 +485,8 @@
   function setUp() {
     parent::setUp();
 
+    drupal_static_reset('format_date');
+
     $web_user = $this->drupalCreateUser(array('create page content', 'administer content types', 'access user profiles'));
     $this->drupalLogin($web_user);
   }
Index: modules/simpletest/tests/common.test
===================================================================
RCS file: /cvs/drupal/drupal/modules/simpletest/tests/common.test,v
retrieving revision 1.57
diff -u -r1.57 common.test
--- modules/simpletest/tests/common.test	30 Jul 2009 19:57:10 -0000	1.57
+++ modules/simpletest/tests/common.test	4 Aug 2009 14:35:34 -0000
@@ -1077,6 +1077,7 @@
 
   function setUp() {
     parent::setUp('locale');
+    drupal_static_reset('format_date');
     variable_set('configurable_timezones', 1);
     variable_set('date_format_long', 'l, j. F Y - G:i');
     variable_set('date_format_medium', 'j. F Y - G:i');
