mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-26 22:34:27 +02:00
8333893: Optimization for StringBuilder append boolean & null
Reviewed-by: liach
This commit is contained in:
parent
c33a8f52b6
commit
5890d9438b
5 changed files with 113 additions and 52 deletions
|
@ -226,17 +226,66 @@ public class StringBuilders {
|
|||
|
||||
|
||||
@Benchmark
|
||||
public String toStringCharWithBool8() {
|
||||
StringBuilder result = new StringBuilder();
|
||||
result.append(true);
|
||||
result.append(false);
|
||||
result.append(true);
|
||||
result.append(true);
|
||||
result.append(false);
|
||||
result.append(true);
|
||||
result.append(false);
|
||||
result.append(false);
|
||||
return result.toString();
|
||||
public int appendWithBool8Latin1() {
|
||||
StringBuilder buf = sbLatin1;
|
||||
buf.setLength(0);
|
||||
buf.append(true);
|
||||
buf.append(false);
|
||||
buf.append(true);
|
||||
buf.append(true);
|
||||
buf.append(false);
|
||||
buf.append(true);
|
||||
buf.append(false);
|
||||
buf.append(false);
|
||||
return buf.length();
|
||||
}
|
||||
|
||||
|
||||
@Benchmark
|
||||
public int appendWithBool8Utf16() {
|
||||
StringBuilder buf = sbUtf16;
|
||||
buf.setLength(0);
|
||||
buf.append(true);
|
||||
buf.append(false);
|
||||
buf.append(true);
|
||||
buf.append(true);
|
||||
buf.append(false);
|
||||
buf.append(true);
|
||||
buf.append(false);
|
||||
buf.append(false);
|
||||
return buf.length();
|
||||
}
|
||||
|
||||
|
||||
@Benchmark
|
||||
public int appendWithNull8Latin1() {
|
||||
StringBuilder buf = sbLatin1;
|
||||
buf.setLength(0);
|
||||
buf.append((String) null);
|
||||
buf.append((String) null);
|
||||
buf.append((String) null);
|
||||
buf.append((String) null);
|
||||
buf.append((String) null);
|
||||
buf.append((String) null);
|
||||
buf.append((String) null);
|
||||
buf.append((String) null);
|
||||
return buf.length();
|
||||
}
|
||||
|
||||
|
||||
@Benchmark
|
||||
public int appendWithNull8Utf16() {
|
||||
StringBuilder buf = sbUtf16;
|
||||
buf.setLength(0);
|
||||
buf.append((String) null);
|
||||
buf.append((String) null);
|
||||
buf.append((String) null);
|
||||
buf.append((String) null);
|
||||
buf.append((String) null);
|
||||
buf.append((String) null);
|
||||
buf.append((String) null);
|
||||
buf.append((String) null);
|
||||
return buf.length();
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue