Index: includes/theme.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/theme.inc,v
retrieving revision 1.557
diff -u -p -r1.557 theme.inc
--- includes/theme.inc	2 Dec 2009 14:56:32 -0000	1.557
+++ includes/theme.inc	16 Dec 2009 00:20:10 -0000
@@ -2234,34 +2234,57 @@ function template_preprocess(&$variables
   $variables['zebra'] = ($count[$hook] % 2) ? 'odd' : 'even';
   $variables['id'] = $count[$hook]++;
 
-  // Tell all templates where they are located.
-  $variables['directory'] = path_to_theme();
+  // Tell all templates where they are located. Using the global variable is
+  // faster than calling path_to_theme().
+  global $theme_path;
+  $variables['directory'] = $theme_path;
 
   // Initialize html class attribute for the current hook.
   $variables['classes_array'] = array($hook);
 
-  // Initialize attributes for the top-level template entity and its title and
-  // content.
-  $variables['attributes_array'] = array();
-  $variables['title_attributes_array'] = array();
-  $variables['content_attributes_array'] = array();
-
-  // Set default variables that depend on the database.
-  $variables['is_admin']            = FALSE;
-  $variables['is_front']            = FALSE;
-  $variables['logged_in']           = FALSE;
-  if ($variables['db_is_active'] = db_is_active()  && !defined('MAINTENANCE_MODE')) {
-    // Check for administrators.
+  // Merge in variables that don't depend on hook and don't change during a
+  // single page request.
+  // Use the advanced drupal_static() pattern, since this is called very often.
+  static $drupal_static = array();
+  isset($drupal_static[__FUNCTION__]) || ($drupal_static[__FUNCTION__] = &drupal_static(__FUNCTION__));
+  $default_variables = &$drupal_static[__FUNCTION__];
+  // Global $user object shouldn't change during a page request once rendering
+  // has started, but if there's an edge case where it does, re-fetch the
+  // variables appropriate for the new user.
+  if (!isset($default_variables) || ($user != $default_variables['user'])) {
+    $default_variables = _template_preprocess_default_variables();
+  }
+  $variables += $default_variables;
+}
+
+/**
+ * Returns hook-independant variables to template_preprocess().
+ */
+function _template_preprocess_default_variables() {
+  global $user;
+
+  $variables = array(
+    'attributes_array' => array(),
+    'title_attributes_array' => array(),
+    'content_attributes_array' => array(),
+    'is_admin' => FALSE,
+    'is_front' => FALSE,
+    'logged_in' => FALSE,
+    'user' => $user,
+    'db_is_active' => db_is_active(),
+  );
+
+  // If database is active and not in maintenance mode, adjust the variables.
+  if ($variables['db_is_active'] && !defined('MAINTENANCE_MODE')) {
     if (user_access('access administration pages')) {
       $variables['is_admin'] = TRUE;
     }
-    // Flag front page status.
     $variables['is_front'] = drupal_is_front_page();
-    // Tell all templates by which kind of user they're viewed.
     $variables['logged_in'] = ($user->uid > 0);
-    // Provide user object to all templates
     $variables['user'] = $user;
   }
+
+  return $variables;
 }
 
 /**
Index: modules/field/field.default.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/field/field.default.inc,v
retrieving revision 1.26
diff -u -p -r1.26 field.default.inc
--- modules/field/field.default.inc	13 Dec 2009 12:41:08 -0000	1.26
+++ modules/field/field.default.inc	16 Dec 2009 00:20:11 -0000
@@ -159,6 +159,7 @@ function field_default_view($obj_type, $
         '#language' => $langcode,
         '#field_name' => $field['field_name'],
         '#field_type' => $field['type'],
+        '#field_translatable' => $field['translatable'],
         '#object_type' => $obj_type,
         '#bundle' => $bundle,
         '#object' => $object,
Index: modules/field/field.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/field/field.module,v
retrieving revision 1.54
diff -u -p -r1.54 field.module
--- modules/field/field.module	13 Dec 2009 12:41:08 -0000	1.54
+++ modules/field/field.module	16 Dec 2009 00:20:11 -0000
@@ -684,13 +684,11 @@ function field_extract_bundle($obj_type,
  */
 function template_preprocess_field(&$variables) {
   $element = $variables['element'];
-  $instance = field_info_instance($element['#object_type'], $element['#field_name'], $element['#bundle']);
-  $field = field_info_field($element['#field_name']);
 
   // @todo Convert to using drupal_html_class() after benchmarking the impact of
   //   doing so.
-  $field_type_css = strtr($field['type'], '_', '-');
-  $field_name_css = strtr($field['field_name'], '_', '-');
+  $field_type_css = strtr($element['#field_type'], '_', '-');
+  $field_name_css = strtr($element['#field_name'], '_', '-');
 
   // Prepare an $items variable that the template can simply loop on.
   // Filter out non-children properties that might have been added if the
@@ -699,20 +697,19 @@ function template_preprocess_field(&$var
 
   $additions = array(
     'object' => $element['#object'],
-    'field' => $field,
-    'instance' => $instance,
     'build_mode' => $element['#build_mode'],
     'items' => $items,
-    'field_type' => $field['type'],
-    'field_name' => $field['field_name'],
+    'field_type' => $element['#field_type'],
+    'field_name' => $element['#field_name'],
     'field_type_css' => $field_type_css,
     'field_name_css' => $field_name_css,
     'label' => check_plain($element['#title']),
     'label_display' => $element['#label_display'],
     'label_hidden' => $element['#label_display'] == 'hidden',
     'field_language' => $element['#language'],
-    'field_translatable' => $field['translatable'],
+    'field_translatable' => $element['#field_translatable'],
     'classes_array' => array(
+      'field',
       'field-name-' . $field_name_css,
       'field-type-' . $field_type_css,
       'field-label-' . $element['#label_display'],
@@ -727,6 +724,7 @@ function template_preprocess_field(&$var
   $variables = array_merge($variables, $additions);
 
   // Initialize attributes for each item.
+  $variables['item_attributes_array'] = array();
   foreach ($variables['items'] as $delta => $item) {
     $variables['item_attributes_array'][$delta] = array();
   }
Index: modules/field/theme/field.tpl.php
===================================================================
RCS file: /cvs/drupal/drupal/modules/field/theme/field.tpl.php,v
retrieving revision 1.8
diff -u -p -r1.8 field.tpl.php
--- modules/field/theme/field.tpl.php	12 Dec 2009 20:16:03 -0000	1.8
+++ modules/field/theme/field.tpl.php	16 Dec 2009 00:20:11 -0000
@@ -13,6 +13,7 @@
  *   CSS. It can be manipulated through the variable $classes_array from
  *   preprocess functions. The default values can be one or more of the
  *   following:
+ *   - field: The current template type, i.e., "theming hook".
  *   - field-name-[field_name]: The current field name. For example, if the
  *     field name is "field_description" it would result in
  *     "field-name-field-description".
@@ -23,7 +24,6 @@
  *
  * Other variables:
  * - $object: The object to which the field is attached.
- * - $field: The field array.
  * - $build_mode: Build mode, e.g. 'full', 'teaser'...
  * - $field_name: The field name.
  * - $field_type: The field type.
@@ -38,7 +38,7 @@
  * @see template_preprocess_field()
  */
 ?>
-<div class="field <?php print $classes; ?> clearfix"<?php print $attributes; ?>>
+<div class="<?php print $classes; ?> clearfix"<?php print $attributes; ?>>
   <?php if (!$label_hidden) : ?>
     <div class="field-label"<?php print $title_attributes; ?>><?php print $label ?>:&nbsp;</div>
   <?php endif; ?>
Index: modules/rdf/rdf.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/rdf/rdf.module,v
retrieving revision 1.12
diff -u -p -r1.12 rdf.module
--- modules/rdf/rdf.module	11 Dec 2009 16:49:40 -0000	1.12
+++ modules/rdf/rdf.module	16 Dec 2009 00:20:12 -0000
@@ -423,14 +423,12 @@ function rdf_preprocess_node(&$variables
  * Implements MODULE_preprocess_HOOK().
  */
 function rdf_preprocess_field(&$variables) {
-  $entity_type = $variables['element']['#object_type'];
-  $instance = $variables['instance'];
-  $mapping = rdf_mapping_load($entity_type, $instance['bundle']);
-  $field_name = $instance['field_name'];
-  $items = $variables['element']['#items'];
+  $element = $variables['element'];
+  $mapping = rdf_mapping_load($element['#object_type'], $element['#bundle']);
+  $field_name = $element['#field_name'];
 
   if (!empty($mapping) && !empty($mapping[$field_name])) {
-    foreach ($items as $delta => $item) {
+    foreach ($element['#items'] as $delta => $item) {
       $variables['item_attributes_array'][$delta] = rdf_rdfa_attributes($mapping[$field_name], $item);
     }
   }
