8325730: StringBuilder.toString allocation for the empty String

Reviewed-by: jlaskey, shade
This commit is contained in:
Claes Redestad 2024-02-20 20:28:55 +00:00
parent aa792eabab
commit d2590c69b4
4 changed files with 25 additions and 5 deletions

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -80,4 +80,10 @@ public class StringBuffers {
return blaha.substring(30, 35);
}
StringBuffer sb = new StringBuffer();
@Benchmark
public String emptyToString() {
return sb.toString();
}
}