You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by ma...@apache.org on 2011/05/23 21:45:31 UTC

svn commit: r1126685 - /myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/compiler/UILeaf.java

Author: martinkoci
Date: Mon May 23 19:45:30 2011
New Revision: 1126685

URL: http://svn.apache.org/viewvc?rev=1126685&view=rev
Log:
MYFACES-3130 [PERF] Avoid unnecessary AbstractList$Itr instances

Modified:
    myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/compiler/UILeaf.java

Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/compiler/UILeaf.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/compiler/UILeaf.java?rev=1126685&r1=1126684&r2=1126685&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/compiler/UILeaf.java (original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/compiler/UILeaf.java Mon May 23 19:45:30 2011
@@ -39,6 +39,8 @@ import javax.faces.event.FacesEvent;
 import javax.faces.event.FacesListener;
 import javax.faces.render.Renderer;
 
+import org.apache.commons.collections.iterators.EmptyIterator;
+
 class UILeaf extends UIComponentBase
 {
 
@@ -170,12 +172,14 @@ class UILeaf extends UIComponentBase
         return null;
     }
 
+    @SuppressWarnings("unchecked")
     @Override
     public Iterator<UIComponent> getFacetsAndChildren()
     {
-        List<UIComponent> childrenAndFacets = Collections.emptyList();
-        
-        return childrenAndFacets.iterator();
+        // Performance: Collections.emptyList() is Singleton,
+        // but .iterator() creates new instance of AbstractList$Itr every invocation, because
+        // emptyList() extends AbstractList.  Therefore we cannot use Collections.emptyList() here. 
+        return EmptyIterator.INSTANCE;
     }
 
     @Override