myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From martink...@apache.org
Subject svn commit: r1130268 - in /myfaces/core/trunk: api/src/main/java/javax/faces/component/ impl/src/main/java/org/apache/myfaces/application/ impl/src/main/java/org/apache/myfaces/view/facelets/
Date Wed, 01 Jun 2011 19:14:10 GMT
Author: martinkoci
Date: Wed Jun  1 19:14:09 2011
New Revision: 1130268

URL: http://svn.apache.org/viewvc?rev=1130268&view=rev
Log:
MYFACES-3155 [perf] reduce (internal) usage of getFacetsAndChildren()

Modified:
    myfaces/core/trunk/api/src/main/java/javax/faces/component/UIComponentBase.java
    myfaces/core/trunk/api/src/main/java/javax/faces/component/UIForm.java
    myfaces/core/trunk/api/src/main/java/javax/faces/component/_ComponentUtils.java
    myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/application/StateManagerImpl.java
    myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/DefaultFaceletsStateManagementStrategy.java

Modified: myfaces/core/trunk/api/src/main/java/javax/faces/component/UIComponentBase.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/api/src/main/java/javax/faces/component/UIComponentBase.java?rev=1130268&r1=1130267&r2=1130268&view=diff
==============================================================================
--- myfaces/core/trunk/api/src/main/java/javax/faces/component/UIComponentBase.java (original)
+++ myfaces/core/trunk/api/src/main/java/javax/faces/component/UIComponentBase.java Wed Jun
 1 19:14:09 2011
@@ -1166,9 +1166,18 @@ public abstract class UIComponentBase ex
                 {
                     // Call the processDecodes() method of all facets and children of this
UIComponent, in the order
                     // determined by a call to getFacetsAndChildren().
-                    for (Iterator<UIComponent> it = getFacetsAndChildren(); it.hasNext();)
+                    int facetCount = getFacetCount();
+                    if (facetCount > 0)
                     {
-                        it.next().processDecodes(context);
+                        for (UIComponent facet : getFacets().values())
+                        {
+                            facet.processDecodes(context);
+                        }
+                    }
+                    for (int i = 0, childCount = getChildCount(); i < childCount; i++)
+                    {
+                        UIComponent child = getChildren().get(i);
+                        child.processDecodes(context);
                     }
     
                     try
@@ -1214,9 +1223,19 @@ public abstract class UIComponentBase ex
                 {
                     // Call the processValidators() method of all facets and children of
this UIComponent, in the order
                     // determined by a call to getFacetsAndChildren().
-                    for (Iterator<UIComponent> it = getFacetsAndChildren(); it.hasNext();)
+                    int facetCount = getFacetCount();
+                    if (facetCount > 0)
+                    {
+                        for (UIComponent facet : getFacets().values())
+                        {
+                            facet.processValidators(context);
+                        }
+                    }
+
+                    for (int i = 0, childCount = getChildCount(); i < childCount; i++)
                     {
-                        it.next().processValidators(context);
+                        UIComponent child = getChildren().get(i);
+                        child.processValidators(context);
                     }
                 }
                 finally
@@ -1254,9 +1273,19 @@ public abstract class UIComponentBase ex
                 {
                     // Call the processUpdates() method of all facets and children of this
UIComponent, in the order
                     // determined by a call to getFacetsAndChildren().
-                    for (Iterator<UIComponent> it = getFacetsAndChildren(); it.hasNext();)
+                    int facetCount = getFacetCount();
+                    if (facetCount > 0)
+                    {
+                        for (UIComponent facet : getFacets().values())
+                        {
+                            facet.processUpdates(context);
+                        }
+                    }
+
+                    for (int i = 0, childCount = getChildCount(); i < childCount; i++)
                     {
-                        it.next().processUpdates(context);
+                        UIComponent child = getChildren().get(i);
+                        child.processUpdates(context);
                     }
                 }
                 finally

Modified: myfaces/core/trunk/api/src/main/java/javax/faces/component/UIForm.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/api/src/main/java/javax/faces/component/UIForm.java?rev=1130268&r1=1130267&r2=1130268&view=diff
==============================================================================
--- myfaces/core/trunk/api/src/main/java/javax/faces/component/UIForm.java (original)
+++ myfaces/core/trunk/api/src/main/java/javax/faces/component/UIForm.java Wed Jun  1 19:14:09
2011
@@ -98,10 +98,22 @@ public class UIForm extends UIComponentB
                 
                 if (!isSubmitted())
                     return;
-                for (Iterator<UIComponent> it = getFacetsAndChildren(); it.hasNext();)
+
+                int facetCount = getFacetCount();
+                if (facetCount > 0)
+                {
+                    for (UIComponent facet : getFacets().values())
+                    {
+                        facet.processDecodes(context);
+                    }
+                }
+                
+                for (int i = 0, childCount = getChildCount(); i < childCount; i++)
                 {
-                    it.next().processDecodes(context);
+                    UIComponent child = getChildren().get(i);
+                    child.processDecodes(context);
                 }
+                
             }
             finally
             {
@@ -141,10 +153,21 @@ public class UIForm extends UIComponentB
                 //Pre validation event dispatch for component
                 context.getApplication().publishEvent(context,  PreValidateEvent.class, getClass(),
this);
                 
-                for (Iterator<UIComponent> it = getFacetsAndChildren(); it.hasNext();)
+                int facetCount = getFacetCount();
+                if (facetCount > 0)
                 {
-                    it.next().processValidators(context);
+                    for (UIComponent facet : getFacets().values())
+                    {
+                        facet.processValidators(context);
+                    }
                 }
+                
+                for (int i = 0, childCount = getChildCount(); i < childCount; i++)
+                {
+                    UIComponent child = getChildren().get(i);
+                    child.processValidators(context);
+                }
+                
             }
             finally
             {
@@ -181,10 +204,21 @@ public class UIForm extends UIComponentB
                 }
                 if (!isSubmitted())
                     return;
-                for (Iterator<UIComponent> it = getFacetsAndChildren(); it.hasNext();)
+                
+                int facetCount = getFacetCount();
+                if (facetCount > 0)
+                {
+                    for (UIComponent facet : getFacets().values()) {
+                        facet.processUpdates(context);
+                    }
+                }
+                
+                for (int i = 0, childCount = getChildCount(); i < childCount; i++)
                 {
-                    it.next().processUpdates(context);
+                    UIComponent child = getChildren().get(i);
+                    child.processUpdates(context);
                 }
+
             }
             finally
             {

Modified: myfaces/core/trunk/api/src/main/java/javax/faces/component/_ComponentUtils.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/api/src/main/java/javax/faces/component/_ComponentUtils.java?rev=1130268&r1=1130267&r2=1130268&view=diff
==============================================================================
--- myfaces/core/trunk/api/src/main/java/javax/faces/component/_ComponentUtils.java (original)
+++ myfaces/core/trunk/api/src/main/java/javax/faces/component/_ComponentUtils.java Wed Jun
 1 19:14:09 2011
@@ -115,18 +115,36 @@ class _ComponentUtils
             return findBase;
         }
 
-        for (Iterator<UIComponent> it = findBase.getFacetsAndChildren(); it.hasNext();)
+        int facetCount = findBase.getFacetCount();
+        if (facetCount > 0)
         {
-            UIComponent childOrFacet = it.next();
-            if (!(childOrFacet instanceof NamingContainer))
+            for (UIComponent facet : findBase.getFacets().values())
             {
-                UIComponent find = findComponent(childOrFacet, id, separatorChar);
+                if (!(facet instanceof NamingContainer))
+                {
+                    UIComponent find = findComponent(facet, id, separatorChar);
+                    if (find != null)
+                        return find;
+                }
+                else if (idsAreEqual(id, facet, separatorChar))
+                {
+                    return facet;
+                }
+            }
+        }
+        
+        for (int i = 0, childCount = findBase.getChildCount(); i < childCount; i++)
+        {
+            UIComponent child = findBase.getChildren().get(i);
+            if (!(child instanceof NamingContainer))
+            {
+                UIComponent find = findComponent(child, id, separatorChar);
                 if (find != null)
                     return find;
             }
-            else if (idsAreEqual(id, childOrFacet, separatorChar))
+            else if (idsAreEqual(id, child, separatorChar))
             {
-                return childOrFacet;
+                return child;
             }
         }
 

Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/application/StateManagerImpl.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/application/StateManagerImpl.java?rev=1130268&r1=1130267&r2=1130268&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/application/StateManagerImpl.java
(original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/application/StateManagerImpl.java
Wed Jun  1 19:14:09 2011
@@ -234,11 +234,18 @@ public class StateManagerImpl extends St
             ids = new HashSet<String>();
         }
         
-        Iterator<UIComponent> it = component.getFacetsAndChildren();
-        while (it.hasNext())
+        int facetCount = component.getFacetCount();
+        if (facetCount > 0)
         {
-            UIComponent kid = it.next();
-            checkForDuplicateIds(context, kid, ids);
+            for (UIComponent facet : component.getFacets().values())
+            {
+                checkForDuplicateIds (context, facet, ids);
+            }
+        }
+        for (int i = 0, childCount = component.getChildCount(); i < childCount; i++)
+        {
+            UIComponent child = component.getChildren().get(i);
+            checkForDuplicateIds (context, child, ids);
         }
     }
 

Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/DefaultFaceletsStateManagementStrategy.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/DefaultFaceletsStateManagementStrategy.java?rev=1130268&r1=1130267&r2=1130268&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/DefaultFaceletsStateManagementStrategy.java
(original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/DefaultFaceletsStateManagementStrategy.java
Wed Jun  1 19:14:09 2011
@@ -786,10 +786,18 @@ public class DefaultFaceletsStateManagem
         
         existingIds.add (id);
         
-        children = component.getFacetsAndChildren();
-        
-        while (children.hasNext()) {
-            checkIds (context, children.next(), existingIds);
+        int facetCount = component.getFacetCount();
+        if (facetCount > 0)
+        {
+            for (UIComponent facet : component.getFacets().values())
+            {
+                checkIds (context, facet, existingIds);
+            }
+        }
+        for (int i = 0, childCount = component.getChildCount(); i < childCount; i++)
+        {
+            UIComponent child = component.getChildren().get(i);
+            checkIds (context, child, existingIds);
         }
     }
     



Mime
View raw message