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

ASF GitHub Bot commented on WICKET-7047:
----------------------------------------

theigl commented on code in PR #579:
URL: https://github.com/apache/wicket/pull/579#discussion_r1168193350


##########
wicket-util/src/main/java/org/apache/wicket/util/string/Strings.java:
##########
@@ -1089,7 +1089,7 @@ public static CharSequence toMultilineMarkup(final 
CharSequence s)
                        return null;
                }
 
-               final AppendingStringBuffer buffer = new 
AppendingStringBuffer();
+               final AppendingStringBuffer buffer = new 
AppendingStringBuffer((int) (s.length() * 1.1));

Review Comment:
   I don't think so. The additional 10% should be enough to accommodate markup 
and escaping overhead in most cases. And if it isn't enough, the buffer is 
resized once. This is *much* better than resizing the buffer almost every time 
as it is now. Imho there is no need to configure or optimize this further.





> Improve initial buffer capacity for Strings.toMultilineMarkup
> -------------------------------------------------------------
>
>                 Key: WICKET-7047
>                 URL: https://issues.apache.org/jira/browse/WICKET-7047
>             Project: Wicket
>          Issue Type: Improvement
>          Components: wicket-core
>    Affects Versions: 9.12.0
>            Reporter: Thomas Heigl
>            Assignee: Thomas Heigl
>            Priority: Major
>
> We currently create an AppendingStringBuffer with default capacity of 16 in 
> Strings#toMultilineMarkup. Since we know the size of the original string and 
> can take a guess at the additional length required for markup, it makes sense 
> to size this buffer appropriately.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to