WhiteCat22 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_r183068721
##########
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();
Review comment:
We don't have hard numbers at the moment, but all of these changes combined
are estimated to improve performance by 1.5%-2% per request depending on load.
Our JDK team analyzed our performance in order to reduce CPU usage and
garbage collection and found that we are creating a large number of
StringBuilders. StringBuilders are expensive to use so only using them when we
need them will improve performance. Similarly, they found that we were using
reflection to get the params every request in
ResourceUtils.createConstructorArguments() which is also expensive, hence the
change to get the params one time in the constructor.
----------------------------------------------------------------
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:
[email protected]
With regards,
Apache Git Services