You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cxf.apache.org by GitBox <gi...@apache.org> on 2018/04/20 16:04:44 UTC

[GitHub] coheigea commented on a change in pull request #407: [CXF-7716] Reduce StringBuilders and other performance changes.

coheigea commented on a change in pull request #407: [CXF-7716] Reduce StringBuilders and other performance changes.
URL: https://github.com/apache/cxf/pull/407#discussion_r183098421
 
 

 ##########
 File path: rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/URITemplate.java
 ##########
 @@ -130,10 +130,31 @@ public String getPatternValue() {
 
     private static String escapeCharacters(String expression) {
 
-        StringBuilder sb = new StringBuilder();
-        for (int i = 0; i < expression.length(); i++) {
-            char ch = expression.charAt(i);
-            sb.append(isReservedCharacter(ch) ? "\\" + ch : ch);
+        int length = expression.length();
+        int i = 0;
+        char ch = ' ';
+        for (; i < length; ++i) {
+            ch = expression.charAt(i);
+            if (isReservedCharacter(ch)) {
+                break;
+            }
+        }
+        
+        if (i == length) {
+            return expression;
+        }
+        
+        StringBuilder sb = new StringBuilder(length + 8);
 
 Review comment:
   There should be a comment in the code in that case explaining why "8" is chosen

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services