myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lu4...@apache.org
Subject svn commit: r1100272 - /myfaces/core/trunk/api/src/main/java/javax/faces/component/UIData.java
Date Fri, 06 May 2011 16:29:18 GMT
Author: lu4242
Date: Fri May  6 16:29:18 2011
New Revision: 1100272

URL: http://svn.apache.org/viewvc?rev=1100272&view=rev
Log:
MYFACES-3111 [PERF] Review UIData.saveDescendantComponentStates and restoreDescendantComponentStates
(thanks to Martin Koci for provide this patch)

Modified:
    myfaces/core/trunk/api/src/main/java/javax/faces/component/UIData.java

Modified: myfaces/core/trunk/api/src/main/java/javax/faces/component/UIData.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/api/src/main/java/javax/faces/component/UIData.java?rev=1100272&r1=1100271&r2=1100272&view=diff
==============================================================================
--- myfaces/core/trunk/api/src/main/java/javax/faces/component/UIData.java (original)
+++ myfaces/core/trunk/api/src/main/java/javax/faces/component/UIData.java Fri May  6 16:29:18
2011
@@ -22,6 +22,7 @@ import java.io.IOException;
 import java.sql.ResultSet;
 import java.util.ArrayList;
 import java.util.Collection;
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
@@ -743,12 +744,10 @@ public class UIData extends UIComponentB
                                                                boolean saveChildFacets)
     {
         Collection<Object[]> childStates = null;
+        boolean hasChildren = childIterator.hasNext();
+        
         while (childIterator.hasNext())
         {
-            if (childStates == null)
-            {
-                childStates = new ArrayList<Object[]>();
-            }
             
             UIComponent child = childIterator.next();
             if (!child.isTransient())
@@ -757,25 +756,38 @@ public class UIData extends UIComponentB
                 // elements. The first element is the state of the children
                 // of this component; the second is the state of the current
                 // child itself.
-
-                Iterator<UIComponent> childsIterator;
-                if (saveChildFacets)
-                {
-                    childsIterator = child.getFacetsAndChildren();
-                }
-                else
+                Object descendantState = null;
+                if (child.getChildCount() > 0)
                 {
-                    childsIterator = child.getChildren().iterator();
+                    Iterator<UIComponent> childsIterator;
+                    if (saveChildFacets)
+                    {
+                        childsIterator = child.getFacetsAndChildren();
+                    }
+                    else
+                    {
+                        childsIterator = child.getChildren().iterator();
+                    }
+
+                    descendantState = saveDescendantComponentStates(childsIterator, true);
                 }
-                Object descendantState = saveDescendantComponentStates(childsIterator, true);
                 Object state = null;
                 if (child instanceof EditableValueHolder)
                 {
                     state = new EditableValueHolderState((EditableValueHolder) child);
                 }
+                if (childStates == null)
+                {
+                    childStates = new ArrayList<Object[]>();
+                }
                 childStates.add(new Object[] { state, descendantState });
             }
         }
+        
+        if (hasChildren == true && childStates == null) {
+            childStates = Collections.emptyList();
+        }
+        
         return childStates;
     }
     



Mime
View raw message