Index: includes/common.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/common.inc,v
retrieving revision 1.1072
diff -u -p -r1.1072 common.inc
--- includes/common.inc	2 Jan 2010 17:39:19 -0000	1.1072
+++ includes/common.inc	3 Jan 2010 03:41:15 -0000
@@ -5026,6 +5026,9 @@ function drupal_render(&$elements) {
     return;
   }
 
+  // Get the children of the element, sorted by weight.
+  $children = element_children($elements, TRUE);
+
   // Initialize this element's #children, unless a #pre_render callback already
   // preset #children.
   if (!isset($elements['#children'])) {
@@ -5040,8 +5043,7 @@ function drupal_render(&$elements) {
   // This is the same process as drupal_render_children() but is inlined
   // for speed.
   if ($elements['#children'] == '') {
-    // Iterate through the children of the element, sorted by weight.
-    foreach (element_children($elements, TRUE) as $key) {
+    foreach ($children as $key) {
       $elements['#children'] .= drupal_render($elements[$key]);
     }
   }
