Skip to content
This repository was archived by the owner on Aug 27, 2022. It is now read-only.
/ lanai Public archive

Commit c52c6c6

Browse files
author
Hamlin Li
committedJan 25, 2021
8260273: DataOutputStream writeChars optimization
Reviewed-by: rriggs, bpb, alanb
1 parent 535c292 commit c52c6c6

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed
 

‎src/java.base/share/classes/java/io/DataOutputStream.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -300,8 +300,9 @@ public final void writeChars(String s) throws IOException {
300300
int len = s.length();
301301
for (int i = 0 ; i < len ; i++) {
302302
int v = s.charAt(i);
303-
out.write((v >>> 8) & 0xFF);
304-
out.write((v >>> 0) & 0xFF);
303+
writeBuffer[0] = (byte)(v >>> 8);
304+
writeBuffer[1] = (byte)(v >>> 0);
305+
out.write(writeBuffer, 0, 2);
305306
}
306307
incCount(len * 2);
307308
}

‎test/micro/org/openjdk/bench/java/io/DataOutputStreamTest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
public class DataOutputStreamTest {
3838

3939
public enum BasicType {CHAR, SHORT, INT, STRING}
40-
@Param({"CHAR", "SHORT", "INT", /* "STRING"*/}) BasicType basicType;
40+
@Param({"CHAR", "SHORT", "INT", "STRING"}) BasicType basicType;
4141

4242
@Param({"4096"}) int size;
4343
final ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(size);

0 commit comments

Comments
 (0)
This repository has been archived.