You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lu...@apache.org on 2012/05/22 13:33:09 UTC

svn commit: r1341415 - /myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/impl/DefaultFaceletContext.java

Author: lu4242
Date: Tue May 22 11:33:08 2012
New Revision: 1341415

URL: http://svn.apache.org/viewvc?rev=1341415&view=rev
Log:
MYFACES-3505 [perf] DefaultFaceletContext : use same StringBuilder instance for prefix and uniqueId (thanks to Martin Koci for provide this patch)

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

Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/impl/DefaultFaceletContext.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/impl/DefaultFaceletContext.java?rev=1341415&r1=1341414&r2=1341415&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/impl/DefaultFaceletContext.java (original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/impl/DefaultFaceletContext.java Tue May 22 11:33:08 2012
@@ -83,7 +83,7 @@ final class DefaultFaceletContext extend
     //private final Map<Integer, Integer> _prefixes;
     private String _prefix;
 
-    private final StringBuilder _uniqueIdBuilder = new StringBuilder(30);
+    private StringBuilder _uniqueIdBuilder;
 
     //private final LinkedList<TemplateManager> _clients;
     
@@ -290,12 +290,12 @@ final class DefaultFaceletContext extend
     {
         if (_prefix == null)
         {
-            StringBuilder builder = new StringBuilder(
+            _uniqueIdBuilder = new StringBuilder(
                     _faceletHierarchy.size() * 30);
             for (int i = 0; i < _faceletHierarchy.size(); i++)
             {
                 AbstractFacelet facelet = _faceletHierarchy.get(i);
-                builder.append(facelet.getFaceletId());
+                _uniqueIdBuilder.append(facelet.getFaceletId());
             }
 
             // Integer prefixInt = new Integer(builder.toString().hashCode());
@@ -304,11 +304,11 @@ final class DefaultFaceletContext extend
             // with htmlunit 2.4 or lower, so in order to prevent it it is better to use
             // only positive values instead.
             // Take into account CompilationManager.nextTagId() uses Math.abs too.
-            Integer prefixInt = new Integer(Math.abs(builder.toString().hashCode()));
+            Integer prefixInt = new Integer(Math.abs(_uniqueIdBuilder.toString().hashCode()));
             _prefix = prefixInt.toString();
         }
 
-        _uniqueIdBuilder.delete(0, _uniqueIdBuilder.length());
+        _uniqueIdBuilder.setLength(0);
         // getFaceletCompositionContext().generateUniqueId() is the one who ensures
         // the final id will be unique, but prefix and base ensure it will be unique
         // per facelet because prefix is calculated from faceletHierarchy and base is