@@ -106,11 +106,11 @@ public static String encodeResourceReferenceAttributes(ResourceReference.UrlAttr
106106 }
107107 else
108108 {
109- StringBuilder res = new StringBuilder (32 );
110- res . append ( encodeStringPart (attributes .getLocale () == null ? null : attributes .getLocale ().toString ()) );
111- res . append ( encodeStringPart (attributes .getStyle ()) );
112- res . append ( encodeStringPart (attributes .getVariation ()) );
113- return res .toString ();
109+ StringBuilder buffer = new StringBuilder (32 );
110+ encodeStringPart (attributes .getLocale () == null ? null : attributes .getLocale ().toString (), buffer );
111+ encodeStringPart (attributes .getStyle (), buffer );
112+ encodeStringPart (attributes .getVariation (), buffer );
113+ return buffer .toString ();
114114 }
115115 }
116116
@@ -228,20 +228,22 @@ public static String readString(IResourceStream resourceStream, Charset charset)
228228 /**
229229 * Encode the {@code part} in the format <string length encoded in base ten ASCII>~<string data>.
230230 *
231- * If the {@code part} is {@code null} the special value {@link #NULL_VALUE} is returned ;
231+ * If the {@code part} is {@code null} the special value {@link #NULL_VALUE} is used ;
232232 *
233233 * @param part
234- * The string to encode
235- * @return The encoded string
234+ * The string to encode.
235+ * @param buffer
236+ * The buffer into which the {@code part} is encoded.
237+ * @return The {@code buffer} for chaining.
236238 */
237- static String encodeStringPart (String part )
239+ static StringBuilder encodeStringPart (String part , StringBuilder buffer )
238240 {
239241 if (part == null ) {
240- return NULL_VALUE ;
242+ return buffer . append ( NULL_VALUE ) ;
241243 }
242244
243245 int length = part .length ();
244- return length + "~" + part ;
246+ return buffer . append ( length ). append ( '~' ). append ( part ) ;
245247 }
246248
247249 /**
0 commit comments