Optimize StringBuilder initialization in CorrelationIdFormatter

Initialize StringBuilder with the expected capacity (this.blank.length())
to avoid unnecessary resizing and array copying during string construction.

The blank field already contains the exact length needed for the formatted
output, making it an ideal initial capacity. This improves performance for
correlation ID formatting, which is frequently called during logging
operations.

See gh-48125

Signed-off-by: gobeomjun <alap_u@naver.com>
This commit is contained in:
gobeomjun
2025-11-14 09:00:07 +00:00
committed by Andy Wilkinson
parent fe07ad8e51
commit d64d60a8f0
@@ -85,7 +85,7 @@ public final class CorrelationIdFormatter {
* @return a formatted correlation id
*/
public String format(UnaryOperator<String> resolver) {
StringBuilder result = new StringBuilder();
StringBuilder result = new StringBuilder(this.blank.length());
formatTo(resolver, result);
return result.toString();
}