mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-26 22:34:27 +02:00
8260273: DataOutputStream writeChars optimization
Reviewed-by: rriggs, bpb, alanb
This commit is contained in:
parent
535c2927b6
commit
c52c6c66db
2 changed files with 4 additions and 3 deletions
|
@ -300,8 +300,9 @@ public class DataOutputStream extends FilterOutputStream implements DataOutput {
|
||||||
int len = s.length();
|
int len = s.length();
|
||||||
for (int i = 0 ; i < len ; i++) {
|
for (int i = 0 ; i < len ; i++) {
|
||||||
int v = s.charAt(i);
|
int v = s.charAt(i);
|
||||||
out.write((v >>> 8) & 0xFF);
|
writeBuffer[0] = (byte)(v >>> 8);
|
||||||
out.write((v >>> 0) & 0xFF);
|
writeBuffer[1] = (byte)(v >>> 0);
|
||||||
|
out.write(writeBuffer, 0, 2);
|
||||||
}
|
}
|
||||||
incCount(len * 2);
|
incCount(len * 2);
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,7 +37,7 @@ import java.util.concurrent.TimeUnit;
|
||||||
public class DataOutputStreamTest {
|
public class DataOutputStreamTest {
|
||||||
|
|
||||||
public enum BasicType {CHAR, SHORT, INT, STRING}
|
public enum BasicType {CHAR, SHORT, INT, STRING}
|
||||||
@Param({"CHAR", "SHORT", "INT", /* "STRING"*/}) BasicType basicType;
|
@Param({"CHAR", "SHORT", "INT", "STRING"}) BasicType basicType;
|
||||||
|
|
||||||
@Param({"4096"}) int size;
|
@Param({"4096"}) int size;
|
||||||
final ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(size);
|
final ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(size);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue