mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 15:24:43 +02:00
8349183: [BACKOUT] Optimization for StringBuilder append boolean & null
8349239: [BACKOUT] Reuse StringLatin1::putCharsAt and StringUTF16::putCharsAt Reviewed-by: redestad, liach
This commit is contained in:
parent
bb837d2f9b
commit
618c5eb27b
6 changed files with 88 additions and 121 deletions
|
@ -274,66 +274,17 @@ public class StringBuilders {
|
|||
}
|
||||
|
||||
@Benchmark
|
||||
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();
|
||||
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();
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue