[ 
https://issues.apache.org/jira/browse/MYFACES-4239?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16523693#comment-16523693
 ] 

ASF GitHub Bot commented on MYFACES-4239:
-----------------------------------------

pnicolucci closed pull request #8: MYFACES-4239: Multiple performance 
improvements
URL: https://github.com/apache/myfaces/pull/8
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git 
a/impl/src/main/java/org/apache/myfaces/application/ApplicationImpl.java 
b/impl/src/main/java/org/apache/myfaces/application/ApplicationImpl.java
index de30135a8..181276855 100755
--- a/impl/src/main/java/org/apache/myfaces/application/ApplicationImpl.java
+++ b/impl/src/main/java/org/apache/myfaces/application/ApplicationImpl.java
@@ -2322,19 +2322,19 @@ private void _handleListenerForAnnotations(FacesContext 
context, Object inspecte
         List<ListenerFor> listenerForList = null;
         boolean isCachedList = false;
         
-        if(isProduction && _classToListenerForMap.containsKey(inspectedClass))
+        if(isProduction)
         {
             listenerForList = _classToListenerForMap.get(inspectedClass);
-            if(listenerForList == null)
-            {
-                return; //class has been inspected and did not contain any 
listener annotations
-            }
-            else if (listenerForList.isEmpty())
+
+            if (listenerForList != null)
             {
-                return;
+                if (listenerForList.isEmpty())
+                {
+                    return; //class has been inspected and did not contain any 
listener annotations
+                }
+                
+                isCachedList = true;    // else annotations were found in the 
cache
             }
-            
-            isCachedList = true;    // else annotations were found in the cache
         }
 
         if(listenerForList == null) //not in production or the class hasn't 
been inspected yet
@@ -2465,19 +2465,19 @@ private void 
_handleResourceDependencyAnnotations(FacesContext context, Class<?>
         List<ResourceDependency> dependencyList = null;
         boolean isCachedList = false;
         
-        if(isProduction && 
_classToResourceDependencyMap.containsKey(inspectedClass))
+        if(isProduction)
         {
             dependencyList = _classToResourceDependencyMap.get(inspectedClass);
-            if(dependencyList == null)
-            {
-                return; //class has been inspected and did not contain any 
resource dependency annotations
-            }
-            else if (dependencyList.isEmpty())
+
+            if (dependencyList != null)
             {
-                return;
+                if (dependencyList.isEmpty())
+                {
+                    return; //class has been inspected and did not contain any 
resource dependency annotations
+                }
+                
+                isCachedList = true;    // else annotations were found in the 
cache
             }
-            
-            isCachedList = true;    // else annotations were found in the cache
         }
         
         if(dependencyList == null)  //not in production or the class hasn't 
been inspected yet
diff --git 
a/impl/src/main/java/org/apache/myfaces/context/servlet/ServletExternalContextImpl.java
 
b/impl/src/main/java/org/apache/myfaces/context/servlet/ServletExternalContextImpl.java
index 8946096f1..a67fc6a62 100755
--- 
a/impl/src/main/java/org/apache/myfaces/context/servlet/ServletExternalContextImpl.java
+++ 
b/impl/src/main/java/org/apache/myfaces/context/servlet/ServletExternalContextImpl.java
@@ -947,11 +947,18 @@ private String encodeURL(String baseUrl, Map<String, 
List<String>> parameters)
             }
         }        
 
+        boolean hasParams = paramMap != null && paramMap.size()>0;
+
+        if (!hasParams && fragment == null) 
+        {
+            return baseUrl;
+        }
+
         // start building the new URL
         StringBuilder newUrl = new StringBuilder(baseUrl);
 
         //now add the updated param list onto the url
-        if (paramMap != null && paramMap.size()>0)
+        if (hasParams)
         {
             boolean isFirstPair = true;
             for (Map.Entry<String, List<String>> pair : paramMap.entrySet())
@@ -989,7 +996,8 @@ private String encodeURL(String baseUrl, Map<String, 
List<String>> parameters)
         //add the fragment back on (if any)
         if (fragment != null)
         {
-            newUrl.append(URL_FRAGMENT_SEPERATOR + fragment);
+            newUrl.append(URL_FRAGMENT_SEPERATOR);
+            newUrl.append(fragment);
         }
 
         return newUrl.toString();
diff --git 
a/shared/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlResponseWriterImpl.java
 
b/shared/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlResponseWriterImpl.java
index d4bb32f31..e60eabd32 100644
--- 
a/shared/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlResponseWriterImpl.java
+++ 
b/shared/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlResponseWriterImpl.java
@@ -91,8 +91,8 @@
     private boolean _isUTF8;
     
     private String _startElementName;
-    private Boolean _isInsideScript;
-    private Boolean _isStyle;
+    private boolean _isInsideScript = false;
+    private boolean _isStyle = false;
     private Boolean _isTextArea;
     private UIComponent _startElementUIComponent;
     private boolean _startTagOpen;
@@ -373,14 +373,14 @@ public void startElement(String name, UIComponent 
uiComponent) throws IOExceptio
         if(isScript(_startElementName))
         {
             // handle a <script> start
-            _isInsideScript = Boolean.TRUE;
-            _isStyle = Boolean.FALSE;
+            _isInsideScript = true;
+            _isStyle = false;
             _isTextArea = Boolean.FALSE;
         }
         else if (isStyle(_startElementName))
         {
-            _isInsideScript = Boolean.FALSE;
-            _isStyle = Boolean.TRUE;
+            _isInsideScript = false;
+            _isStyle = true;
             _isTextArea = Boolean.FALSE;
         }
     }
@@ -516,7 +516,7 @@ private void resetStartedElement()
         _startElementName = null;
         _startElementUIComponent = null;
         _passThroughAttributesMap = null;
-        _isStyle = null;
+        _isStyle = false;
         _isTextArea = null;
     }
 
@@ -798,11 +798,11 @@ private void writeEndTag(String name)
         if (isScript(name))
         {
             // reset _isInsideScript
-            _isInsideScript = Boolean.FALSE;
+            _isInsideScript = false;
         }
         else if (isStyle(name))
         {
-            _isStyle = Boolean.FALSE;
+            _isStyle = false;
         }
 
         _currentWriter.write("</");
@@ -925,7 +925,7 @@ private void encodeAndWriteURIAttribute(String name, Object 
value) throws IOExce
             }
             */
             //_writer.write(strValue);
-            
org.apache.myfaces.shared.renderkit.html.util.HTMLEncoder.encodeURIAtributte(_currentWriter,
+            
org.apache.myfaces.shared.renderkit.html.util.HTMLEncoder.encodeURIAttribute(_currentWriter,
                             strValue, _characterEncoding);
         }
         _currentWriter.write('"');
@@ -1018,8 +1018,7 @@ private boolean isScriptOrStyle()
     {
         //initializeStartedTagInfo();
 
-        return (_isStyle != null && _isStyle.booleanValue()) ||
-                (_isInsideScript != null && _isInsideScript.booleanValue());
+        return _isStyle || _isInsideScript;
     }
     
     /**
@@ -1034,7 +1033,7 @@ private boolean isScript(String element)
     
     private boolean isScript()
     {
-        return (_isInsideScript != null && _isInsideScript.booleanValue());
+        return _isInsideScript;
     }
     
     private boolean isStyle(String element)
@@ -1044,7 +1043,7 @@ private boolean isStyle(String element)
     
     private boolean isStyle()
     {
-        return (_isStyle != null && _isStyle.booleanValue());
+        return _isStyle;
     }
 
     private boolean isTextarea()
diff --git 
a/shared/src/main/java/org/apache/myfaces/shared/renderkit/html/util/HTMLEncoder.java
 
b/shared/src/main/java/org/apache/myfaces/shared/renderkit/html/util/HTMLEncoder.java
index 1b58d9237..30bcd2c12 100644
--- 
a/shared/src/main/java/org/apache/myfaces/shared/renderkit/html/util/HTMLEncoder.java
+++ 
b/shared/src/main/java/org/apache/myfaces/shared/renderkit/html/util/HTMLEncoder.java
@@ -71,10 +71,13 @@ public static String encode (String string,
 
         StringBuilder sb = null;    //create later on demand
         String app;
-        char c;
-        for (int i = 0; i < string.length (); ++i)
+        char c = ' ';
+        char prevC;
+        int length = string.length();
+        for (int i = 0; i < length; ++i)
         {
             app = null;
+            prevC = c;
             c = string.charAt(i);
             
             // All characters before letters
@@ -88,7 +91,7 @@ public static String encode (String string,
                     case '>': app = "&gt;"; break;      //>
                     case ' ':
                         if (encodeSubsequentBlanksToNbsp &&
-                                (i == 0 || (i - 1 >= 0 && string.charAt(i - 1) 
== ' ')))
+                                prevC == ' ')
                         {
                             //Space at beginning or after another space
                             app = "&#160;";
@@ -202,10 +205,13 @@ public static void encode (Writer writer, String string,
 
         int start = 0;
         String app;
-        char c;
-        for (int i = 0; i < string.length (); ++i)
+        char c = ' ';
+        char prevC;
+        int length = string.length();
+        for (int i = 0; i < length; ++i)
         {
             app = null;
+            prevC = c;
             c = string.charAt(i);
             
             // All characters before letters
@@ -219,7 +225,7 @@ public static void encode (Writer writer, String string,
                     case '>': app = "&gt;"; break;      //>
                     case ' ':
                         if (encodeSubsequentBlanksToNbsp &&
-                                (i == 0 || (i - 1 >= 0 && string.charAt(i - 1) 
== ' ')))
+                                prevC == ' ')
                         {
                             //Space at beginning or after another space
                             app = "&#160;";
@@ -304,9 +310,9 @@ else if (encodeNonLatin && (int)c > 0x80)
         {
             writer.write(string);
         }
-        else if (start < string.length())
+        else if (start < length)
         {
-            writer.write(string,start,string.length()-start);
+            writer.write(string,start,length-start);
         }
     }
 
@@ -359,12 +365,14 @@ public static void encode (char[] string, int offset, int 
length,
 
         //StringBuilder sb = null;    //create later on demand
         String app;
-        char c;
+        char c = ' ';
+        char prevC;
         int start = offset;
         
         for (int i = offset; i < offset + realLength; ++i)
         {
             app = null;
+            prevC = c;
             c = string[i];
 
             // All characters before letters
@@ -378,7 +386,7 @@ public static void encode (char[] string, int offset, int 
length,
                     case '>': app = "&gt;"; break;      //>
                     case ' ':
                         if (encodeSubsequentBlanksToNbsp &&
-                                (i == 0 || (i - 1 >= 0 && string[i - 1] == ' 
')))
+                                prevC == ' ')
                         {
                             //Space at beginning or after another space
                             app = "&#160;";
@@ -484,14 +492,15 @@ else if (start < offset+realLength)
      * @return
      * @throws IOException
      */
-    public static String encodeURIAtributte(final String string, final String 
characterEncoding)
+    public static String encodeURIAttribute(final String string, final String 
characterEncoding)
         throws IOException
     {
         StringBuilder sb = null;    //create later on demand
         String app;
         char c;
         boolean endLoop = false;
-        for (int i = 0; i < string.length (); ++i)
+        int length = string.length();
+        for (int i = 0; i < length; ++i)
         {
             app = null;
             c = string.charAt(i);
@@ -632,7 +641,7 @@ public static String encodeURIAtributte(final String 
string, final String charac
             }
             else if (c == '%')
             {
-                if (i + 2 < string.length())
+                if (i + 2 < length)
                 {
                     char c1 = string.charAt(i+1);
                     char c2 = string.charAt(i+2);
@@ -654,7 +663,7 @@ else if (c == '%')
             }
             else if (c == '?' || c == '#')
             {
-                if (i+1 < string.length())
+                if (i+1 < length)
                 {
                     // The remaining part of the URI are data that should be 
encoded
                     // using the document character encoding.
@@ -762,7 +771,8 @@ private static String encodeURIQuery(final String string, 
final String character
         String app;
         char c;
         boolean endLoop = false;
-        for (int i = 0; i < string.length (); ++i)
+        int length = string.length();
+        for (int i = 0; i < length; ++i)
         {
             app = null;
             c = string.charAt(i);
@@ -791,7 +801,7 @@ private static String encodeURIQuery(final String string, 
final String character
             }
             else if (c == '%')
             {
-                if (i + 2 < string.length())
+                if (i + 2 < length)
                 {
                     char c1 = string.charAt(i+1);
                     char c2 = string.charAt(i+2);
@@ -812,7 +822,7 @@ else if (c == '%')
             }
             else if (c == '&')
             {
-                if (i+4 < string.length() )
+                if (i+4 < length )
                 {
                     if ('a' == string.charAt(i+1) &&
                         'm' == string.charAt(i+2) &&
@@ -875,7 +885,7 @@ else if (c == '&')
      * @param characterEncoding
      * @throws IOException
      */
-    public static void encodeURIAtributte(Writer writer, final String string, 
final String characterEncoding)
+    public static void encodeURIAttribute(Writer writer, final String string, 
final String characterEncoding)
         throws IOException
     {
         //StringBuilder sb = null;    //create later on demand
@@ -883,7 +893,8 @@ public static void encodeURIAtributte(Writer writer, final 
String string, final
         String app;
         char c;
         boolean endLoop = false;
-        for (int i = 0; i < string.length (); ++i)
+        int length = string.length();
+        for (int i = 0; i < length; ++i)
         {
             app = null;
             c = string.charAt(i);
@@ -1030,7 +1041,7 @@ public static void encodeURIAtributte(Writer writer, 
final String string, final
             }
             else if (c == '%')
             {
-                if (i + 2 < string.length())
+                if (i + 2 < length)
                 {
                     char c1 = string.charAt(i+1);
                     char c2 = string.charAt(i+2);
@@ -1064,7 +1075,7 @@ else if (c == '%')
             }
             else if (c == '?' || c == '#')
             {
-                if (i+1 < string.length())
+                if (i+1 < length)
                 {
                     // The remaining part of the URI are data that should be 
encoded
                     // using the document character encoding.
@@ -1108,7 +1119,7 @@ else if (c == '?' || c == '#')
             //}
             if (endLoop)
             {
-                start = string.length();
+                start = length;
                 break;
             }
         }
@@ -1124,9 +1135,9 @@ else if (c == '?' || c == '#')
         {
             writer.write(string);
         }
-        else if (start < string.length())
+        else if (start < length)
         {
-            writer.write(string,start,string.length()-start);
+            writer.write(string,start,length-start);
         }
     }
 
@@ -1202,11 +1213,12 @@ private static void encodeURIQuery(Writer writer, final 
String string, int offse
     {
         //StringBuilder sb = null;    //create later on demand
         int start = offset;
-        int realLength = string.length()-offset;
+        int length = string.length();
+        int realLength = length-offset;
         String app;
         char c;
         //boolean endLoop = false;
-        for (int i = offset; i < offset+realLength; ++i)
+        for (int i = offset; i < length; ++i)
         {
             app = null;
             c = string.charAt(i);
@@ -1241,7 +1253,7 @@ private static void encodeURIQuery(Writer writer, final 
String string, int offse
             }
             else if (c == '%')
             {
-                if (i + 2 < string.length())
+                if (i + 2 < length)
                 {
                     char c1 = string.charAt(i+1);
                     char c2 = string.charAt(i+2);
@@ -1274,7 +1286,7 @@ else if (c == '%')
             }
             else if (c == '&')
             {
-                if (i+4 < string.length() )
+                if (i+4 < length )
                 {
                     if ('a' == string.charAt(i+1) &&
                         'm' == string.charAt(i+2) &&
@@ -1337,9 +1349,9 @@ else if (c == '&')
         {
             writer.write(string, offset, realLength);
         }
-        else if (start < offset+realLength)
+        else if (start < length)
         {
-            writer.write(string,start,offset+realLength-start);
+            writer.write(string,start,length-start);
         }
     }
 }
diff --git 
a/shared/src/main/java/org/apache/myfaces/shared/resource/ResourceValidationUtils.java
 
b/shared/src/main/java/org/apache/myfaces/shared/resource/ResourceValidationUtils.java
index 5681deae8..48d883fb5 100644
--- 
a/shared/src/main/java/org/apache/myfaces/shared/resource/ResourceValidationUtils.java
+++ 
b/shared/src/main/java/org/apache/myfaces/shared/resource/ResourceValidationUtils.java
@@ -39,8 +39,8 @@ public static boolean isValidResourceId(String resourceId)
     {
         // Follow the same rules as for resourceName, but check resourceId 
does not
         // start with '/'
-        return validateResourceName(resourceId, true) && 
-            resourceId.length() > 0 && resourceId.charAt(0) != '/';
+        return resourceId.length() > 0 && resourceId.charAt(0) != '/' && 
+            validateResourceName(resourceId, true); 
     }
     
     public static boolean isValidViewResource(String resourceId)
@@ -57,7 +57,7 @@ public static boolean isValidContractName(String contractName)
     
     public static boolean isValidLocalePrefix(String localePrefix)
     {
-        for (int i = 0; i < localePrefix.length(); i++)
+        for (int i = 0, length = localePrefix.length(); i < length; i++)
         {
             char c = localePrefix.charAt(i);
             if ( (c >='A' && c <='Z') || c == '_' || (c >='a' && c <='z') || 
(c >='0' && c <='9') )
@@ -79,13 +79,14 @@ public static boolean isValidPath(String path)
     
     private static boolean validate(String expression, boolean allowSlash)
     {
-        if (expression.length() == 2 && 
+        int length = expression.length();
+        if (length == 2 && 
             expression.charAt(0) == '.' &&
             expression.charAt(1) == '.')
         {
             return false;
         }
-        for (int i = 0; i < expression.length(); i++)
+        for (int i = 0; i < length; i++)
         {
             char c = expression.charAt(i);
 
@@ -113,7 +114,7 @@ private static boolean validate(String expression, boolean 
allowSlash)
             }
             else if (c == '.')
             {
-                if (i+2 < expression.length())
+                if (i+2 < length)
                 {
                     char c1 = expression.charAt(i+1);
                     char c2 = expression.charAt(i+2);
@@ -129,9 +130,8 @@ else if (c == '.')
                 return false;
             }
         }
-        if (expression.length() >= 3)
+        if (length >= 3)
         {
-            int length = expression.length();
             if ( (expression.charAt(length-3) == '/' || 
expression.charAt(length-3) == '\\' ) && 
                   expression.charAt(length-2) == '.' &&
                   expression.charAt(length-1) == '.' )
@@ -144,13 +144,14 @@ else if (c == '.')
     
     private static boolean validateResourceName(String expression, boolean 
allowSlash)
     {
-        if (expression.length() == 2 && 
+        int length = expression.length();
+        if (length == 2 && 
             expression.charAt(0) == '.' &&
             expression.charAt(1) == '.')
         {
             return false;
         }
-        for (int i = 0; i < expression.length(); i++)
+        for (int i = 0; i < length; i++)
         {
             char c = expression.charAt(i);
 
@@ -193,7 +194,7 @@ private static boolean validateResourceName(String 
expression, boolean allowSlas
             }
             else if (c == '.')
             {
-                if (i+2 < expression.length())
+                if (i+2 < length)
                 {
                     char c1 = expression.charAt(i+1);
                     char c2 = expression.charAt(i+2);
@@ -209,9 +210,8 @@ else if (c == '.')
                 return false;
             }
         }
-        if (expression.length() >= 3)
+        if (length >= 3)
         {
-            int length = expression.length();
             if ( (expression.charAt(length-3) == '/' || 
expression.charAt(length-3) == '\\' ) && 
                   expression.charAt(length-2) == '.' &&
                   expression.charAt(length-1) == '.' )
diff --git 
a/shared/src/test/java/org/apache/myfaces/shared/renderkit/html/util/HTMLEncoderTest.java
 
b/shared/src/test/java/org/apache/myfaces/shared/renderkit/html/util/HTMLEncoderTest.java
index 856036596..d5b808c79 100644
--- 
a/shared/src/test/java/org/apache/myfaces/shared/renderkit/html/util/HTMLEncoderTest.java
+++ 
b/shared/src/test/java/org/apache/myfaces/shared/renderkit/html/util/HTMLEncoderTest.java
@@ -242,7 +242,7 @@ public void testSimpleWriteURIAttribute() throws Exception
   {
       String cad1 = 
"http://myfaces.apache.org/hello.jsf?key1=val&key2=val2#id";;
       String cad2 = 
"http://myfaces.apache.org/hello.jsf?key1=val&amp;key2=val2#id";;
-      String cad3 = HTMLEncoder.encodeURIAtributte(cad1,"UTF-8");
+      String cad3 = HTMLEncoder.encodeURIAttribute(cad1,"UTF-8");
       assertEquals(cad2, cad3);      
   }
   
@@ -257,12 +257,12 @@ public void testUsAsciiEscapedCharactersBeforeQuery() 
throws Exception
       // - From %7F ad infinitum
       String cad1 = "?key=\"%<>\\`{|}^\n "; //Omit %
       String cad2 = "?key=%22%25%3C%3E%5C%60%7B%7C%7D%5E%0A%20";
-      String cad3 = HTMLEncoder.encodeURIAtributte(cad1,"UTF-8");
+      String cad3 = HTMLEncoder.encodeURIAttribute(cad1,"UTF-8");
       assertEquals(cad2, cad3);
       
       String cad4 = "\"%<>\\`{|}^\n ";
       String cad5 = "%22%25%3C%3E%5C%60%7B%7C%7D%5E%0A%20";
-      String cad6 = HTMLEncoder.encodeURIAtributte(cad4,"UTF-8");
+      String cad6 = HTMLEncoder.encodeURIAttribute(cad4,"UTF-8");
       assertEquals(cad5, cad6);
       
       
@@ -279,12 +279,12 @@ public void 
testUsAsciiEscapedCharactersBeforeQueryLowerCase() throws Exception
       // - From %7F ad infinitum
       String cad1 = "?key=\"%<>\\`{|}^\n "; //Omit %
       String cad2 = "?key=%22%25%3c%3e%5c%60%7b%7c%7d%5e%0a%20";
-      String cad3 = HTMLEncoder.encodeURIAtributte(cad1,"UTF-8");
+      String cad3 = HTMLEncoder.encodeURIAttribute(cad1,"UTF-8");
       assertEquals(cad2.substring(0,5) + cad2.substring(5).toUpperCase(), 
cad3);
       
       String cad4 = "\"%<>\\`{|}^\n ";
       String cad5 = "%22%25%3c%3e%5c%60%7b%7c%7d%5e%0a%20";
-      String cad6 = HTMLEncoder.encodeURIAtributte(cad4,"UTF-8");
+      String cad6 = HTMLEncoder.encodeURIAttribute(cad4,"UTF-8");
       assertEquals(cad5.substring(0,5) + cad5.substring(5).toUpperCase(), 
cad6);
       
   }  
@@ -296,7 +296,7 @@ public void testWriteNonUsAsciiOnURIAttribute() throws 
Exception
          byte [] array = new byte[]{(byte)0xFC};
       String cad1 = new 
String(array,"ISO-8859-1");//+(char)0xC3BC;//"http://myfaces.apache.org/heüll 
o.jsf?key=val#id";
       String cad2 = 
"%C3%BC";//"http://myfaces.apache.org/he%FCll%20o.jsf?key=val#id";;
-      String cad3 = HTMLEncoder.encodeURIAtributte(cad1,"UTF-8");
+      String cad3 = HTMLEncoder.encodeURIAttribute(cad1,"UTF-8");
       assertEquals(cad2, cad3);
 
   }
@@ -312,11 +312,11 @@ public void testReservedCharactersOnURIAttribute() throws 
Exception
       //               %21   %24   %26   %27   %28   %29   %2A   %2B   %2C   
%3B   %3D
       
       String cad1 = "?key=:/[]@!$'()*+,;="; //Omit &
-      String cad2 = HTMLEncoder.encodeURIAtributte(cad1,"UTF-8");
+      String cad2 = HTMLEncoder.encodeURIAttribute(cad1,"UTF-8");
       assertEquals(cad1, cad2);
       
       String cad7 = ":/[]@!$&'()*+,;=";
-      String cad8 = HTMLEncoder.encodeURIAtributte(cad7,"UTF-8");
+      String cad8 = HTMLEncoder.encodeURIAttribute(cad7,"UTF-8");
       assertEquals(cad7, cad8);
   }
 
@@ -327,15 +327,15 @@ public void testNonEncodedCharactersOnURIAttribute() 
throws Exception
       // underscore (%5F), or tilde (%7E) should not be created by URI
       // producers...."
       String cad1 = 
"?key=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~";
-      String cad2 = HTMLEncoder.encodeURIAtributte(cad1,"UTF-8");
+      String cad2 = HTMLEncoder.encodeURIAttribute(cad1,"UTF-8");
       assertEquals(cad1, cad2);
       
       String cad3 = 
"#somefile?key=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~";
-      String cad4 = HTMLEncoder.encodeURIAtributte(cad3,"UTF-8");
+      String cad4 = HTMLEncoder.encodeURIAttribute(cad3,"UTF-8");
       assertEquals(cad3, cad4);
       
       String cad5 = 
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~";
-      String cad6 = HTMLEncoder.encodeURIAtributte(cad5,"UTF-8");
+      String cad6 = HTMLEncoder.encodeURIAttribute(cad5,"UTF-8");
       assertEquals(cad5, cad6);
   }
 
@@ -353,17 +353,17 @@ public void testWriteURIAttribute() throws Exception
       String cad11 = new String(array11,"UTF-8") + 
((char)(0xFF))+((char)(0x100));
       String cad12 = 
"%C2%A1%C2%A2%C2%A3%C2%A4%C2%A5%C2%A6%C2%A7%C2%A8%C2%A9%C2%AA%C2%AB%C2%AC%C2%AD"+
                      "%C2%AE%C2%AF%C2%B0%C2%B1%C3%BF%C4%80";
-      String cad13 = HTMLEncoder.encodeURIAtributte(cad11,"UTF-8");
+      String cad13 = HTMLEncoder.encodeURIAttribute(cad11,"UTF-8");
       assertEquals(cad12, cad13);
       
       String cad1= "?key=" + new 
String(array11,"UTF-8")+((char)(0xFF))+((char)(0x100));
       String cad2 = 
"?key=%C2%A1%C2%A2%C2%A3%C2%A4%C2%A5%C2%A6%C2%A7%C2%A8%C2%A9%C2%AA%C2%AB%C2%AC%C2%AD"+
                      "%C2%AE%C2%AF%C2%B0%C2%B1%C3%BF%C4%80";
-      String cad3 = HTMLEncoder.encodeURIAtributte(cad1,"UTF-8");
+      String cad3 = HTMLEncoder.encodeURIAttribute(cad1,"UTF-8");
       assertEquals(cad2, cad3);
             
       //String cad14 = 
"http://myfaces.apache.org/page.jsf?key="+((char)0xFF)+((char)0x100);
-      //String cad15 = HTMLEncoder.encodeURIAtributte(cad14,false);
+      //String cad15 = HTMLEncoder.encodeURIAttribute(cad14,false);
       //assertEquals(cad14,cad15);
   }
     
diff --git 
a/shared/src/test/java/org/apache/myfaces/shared/renderkit/html/util/HTMLEncoderWriterTest.java
 
b/shared/src/test/java/org/apache/myfaces/shared/renderkit/html/util/HTMLEncoderWriterTest.java
index 099898de7..b16a68fee 100644
--- 
a/shared/src/test/java/org/apache/myfaces/shared/renderkit/html/util/HTMLEncoderWriterTest.java
+++ 
b/shared/src/test/java/org/apache/myfaces/shared/renderkit/html/util/HTMLEncoderWriterTest.java
@@ -252,7 +252,7 @@ private void assertEquals(char[] expected, char[] actual) {
   {
       String cad1 = 
"http://myfaces.apache.org/hello.jsf?key1=val&key2=val2#id";;
       String cad2 = 
"http://myfaces.apache.org/hello.jsf?key1=val&amp;key2=val2#id";;
-      HTMLEncoder.encodeURIAtributte(sw, cad1,"UTF-8");
+      HTMLEncoder.encodeURIAttribute(sw, cad1,"UTF-8");
       String cad3 = sw.toString();
       assertEquals(cad2, cad3);      
   }
@@ -268,14 +268,14 @@ public void testUsAsciiEscapedCharactersBeforeQuery() 
throws Exception
       // - From %7F ad infinitum
       String cad1 = "?key=\"%<>\\`{|}^\n "; //Omit %
       String cad2 = "?key=%22%25%3C%3E%5C%60%7B%7C%7D%5E%0A%20";
-      HTMLEncoder.encodeURIAtributte(sw, cad1,"UTF-8");
+      HTMLEncoder.encodeURIAttribute(sw, cad1,"UTF-8");
       String cad3 = sw.toString();
       assertEquals(cad2, cad3);
       
       String cad4 = "\"%<>\\`{|}^\n ";
       String cad5 = "%22%25%3C%3E%5C%60%7B%7C%7D%5E%0A%20";
       sw = new StringWriter();
-      HTMLEncoder.encodeURIAtributte(sw, cad4,"UTF-8");
+      HTMLEncoder.encodeURIAttribute(sw, cad4,"UTF-8");
       String cad6 = sw.toString();
       assertEquals(cad5, cad6);
       
@@ -289,7 +289,7 @@ public void testWriteNonUsAsciiOnURIAttribute() throws 
Exception
          byte [] array = new byte[]{(byte)0xFC};
       String cad1 = new 
String(array,"ISO-8859-1");//+(char)0xC3BC;//"http://myfaces.apache.org/heüll 
o.jsf?key=val#id";
       String cad2 = 
"%C3%BC";//"http://myfaces.apache.org/he%FCll%20o.jsf?key=val#id";;
-      HTMLEncoder.encodeURIAtributte(sw, cad1,"UTF-8");
+      HTMLEncoder.encodeURIAttribute(sw, cad1,"UTF-8");
       String cad3 = sw.toString();
       assertEquals(cad2, cad3);
 
@@ -306,13 +306,13 @@ public void testReservedCharactersOnURIAttribute() throws 
Exception
       //               %21   %24   %26   %27   %28   %29   %2A   %2B   %2C   
%3B   %3D
       
       String cad1 = "?key=:/[]@!$'()*+,;="; //Omit &
-      HTMLEncoder.encodeURIAtributte(sw, cad1,"UTF-8");
+      HTMLEncoder.encodeURIAttribute(sw, cad1,"UTF-8");
       String cad2 = sw.toString();
       assertEquals(cad1, cad2);
       
       String cad7 = ":/[]@!$&'()*+,;=";
       sw = new StringWriter(40);
-      HTMLEncoder.encodeURIAtributte(sw, cad7,"UTF-8");
+      HTMLEncoder.encodeURIAttribute(sw, cad7,"UTF-8");
       String cad8 = sw.toString();
       assertEquals(cad7, cad8);
   }
@@ -324,19 +324,19 @@ public void testNonEncodedCharactersOnURIAttribute() 
throws Exception
       // underscore (%5F), or tilde (%7E) should not be created by URI
       // producers...."
       String cad1 = 
"?key=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~";
-      HTMLEncoder.encodeURIAtributte(sw, cad1,"UTF-8");
+      HTMLEncoder.encodeURIAttribute(sw, cad1,"UTF-8");
       String cad2 = sw.toString();
       assertEquals(cad1, cad2);
       
       String cad3 = 
"#somefile?key=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~";
       sw = new StringWriter(40);
-      HTMLEncoder.encodeURIAtributte(sw, cad3,"UTF-8");
+      HTMLEncoder.encodeURIAttribute(sw, cad3,"UTF-8");
       String cad4 = sw.toString();
       assertEquals(cad3, cad4);
       
       String cad5 = 
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~";
       sw = new StringWriter(40);
-      HTMLEncoder.encodeURIAtributte(sw, cad5,"UTF-8");
+      HTMLEncoder.encodeURIAttribute(sw, cad5,"UTF-8");
       String cad6 = sw.toString();
       assertEquals(cad5, cad6);
   }
@@ -355,7 +355,7 @@ public void testWriteURIAttribute() throws Exception
       String cad11 = new String(array11,"UTF-8") + 
((char)(0xFF))+((char)(0x100));
       String cad12 = 
"%C2%A1%C2%A2%C2%A3%C2%A4%C2%A5%C2%A6%C2%A7%C2%A8%C2%A9%C2%AA%C2%AB%C2%AC%C2%AD"+
                      "%C2%AE%C2%AF%C2%B0%C2%B1%C3%BF%C4%80";
-      HTMLEncoder.encodeURIAtributte(sw, cad11,"UTF-8");
+      HTMLEncoder.encodeURIAttribute(sw, cad11,"UTF-8");
       String cad13 = sw.toString();
       assertEquals(cad12, cad13);
       
@@ -363,12 +363,12 @@ public void testWriteURIAttribute() throws Exception
       String cad2 = 
"?key=%C2%A1%C2%A2%C2%A3%C2%A4%C2%A5%C2%A6%C2%A7%C2%A8%C2%A9%C2%AA%C2%AB%C2%AC%C2%AD"+
                      "%C2%AE%C2%AF%C2%B0%C2%B1%C3%BF%C4%80";
       sw = new StringWriter(40);
-      HTMLEncoder.encodeURIAtributte(sw, cad1,"UTF-8");
+      HTMLEncoder.encodeURIAttribute(sw, cad1,"UTF-8");
       String cad3 = sw.toString();
       assertEquals(cad2, cad3);
             
       //String cad14 = 
"http://myfaces.apache.org/page.jsf?key="+((char)0xFF)+((char)0x100);
-      //String cad15 = HTMLEncoder.encodeURIAtributte(cad14,false);
+      //String cad15 = HTMLEncoder.encodeURIAttribute(cad14,false);
       //assertEquals(cad14,cad15);
   }
     


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> [perf] Additional performance improvements
> ------------------------------------------
>
>                 Key: MYFACES-4239
>                 URL: https://issues.apache.org/jira/browse/MYFACES-4239
>             Project: MyFaces Core
>          Issue Type: Improvement
>          Components: JSR-372
>    Affects Versions: 2.2.12, 2.3.1
>            Reporter: Paul Nicolucci
>            Assignee: Paul Nicolucci
>            Priority: Minor
>             Fix For: 2.2.13, 2.3.2
>
>
> Some performance improvements in :
> 1) ApplicationImpl.java 
> 2) ServletExternalContextImpl.java
> 3) HtmlResponseWriterImpl.java
> 4) HTMLEncoder.java, we also discussed on the mailing list changing 
> encodeURIAtributte to encodeUriAttribute to fix the typo in the method name 
> so I'll do that here as well.
> 5) ResourceValidationUtils.java
> The following changes were made:
> -  Skip calling ConcurrentHashMap.containsKey since we will call get
> afterward if containsKey == true.
> - Stop using Boolean for variables that don't have a null meaning. If
> null == false, then just use boolean with a default of false.
> - Don't call String.length() constantly for String variables that aren't 
> re-assigned.
> - Change conditional order to avoid calling validateResourceName unless the 
> other conditions are true



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to