mirror of
https://github.com/spring-projects/spring-boot.git
synced 2026-10-01 23:09:01 +00:00
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:
committed by
Andy Wilkinson
parent
fe07ad8e51
commit
d64d60a8f0
+1
-1
@@ -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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user