You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by GitBox <gi...@apache.org> on 2022/05/05 08:55:42 UTC
[GitHub] [wicket] martin-g commented on a diff in pull request #523: Reduce object creation and wasted memory in Url toString() methods
martin-g commented on code in PR #523:
URL: https://github.com/apache/wicket/pull/523#discussion_r865691679
##########
wicket-request/src/main/java/org/apache/wicket/request/Url.java:
##########
@@ -747,8 +747,26 @@ public String toString()
*/
public String toString(StringMode mode, Charset charset)
{
- StringBuilder result = new StringBuilder();
- final String path = getPath(charset);
+ // this method is rarely called with StringMode == FULL.
+
+ final CharSequence path = getPathInternal(charset);
+ final String queryString = getQueryString(charset);
+ String _fragment = getFragment();
+
+ // short circuit all the processing in the most common cases
+ if (StringMode.FULL != mode && Strings.isEmpty(_fragment))
+ {
+ if (queryString == null) {
+ return path.toString();
+ }
+ else {
+ return path + "?" + queryString;
+ }
+ }
+
+ // fall through into the traditional code path
+
+ StringBuilder result = new StringBuilder(64;
Review Comment:
missing closing `)`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@wicket.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org