Index: includes/common.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/common.inc,v
retrieving revision 1.1048
diff -u -r1.1048 common.inc
--- includes/common.inc	16 Nov 2009 05:15:21 -0000	1.1048
+++ includes/common.inc	16 Nov 2009 18:09:30 -0000
@@ -4971,9 +4971,6 @@ function drupal_render(&$elements) {
     }
   }
 
-  // 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'])) {
@@ -4988,7 +4985,8 @@
   // This is the same process as drupal_render_children() but is inlined
   // for speed.
   if ($elements['#children'] == '') {
-    foreach ($children as $key) {
+    // Iterate through the children of the element, sorted by weight.
+    foreach (element_children($elements, TRUE) as $key) {
       $elements['#children'] .= drupal_render($elements[$key]);
     }
   }
