8260273: DataOutputStream writeChars optimization

Reviewed-by: rriggs, bpb, alanb
This commit is contained in:
Hamlin Li 2021-01-25 01:05:40 +00:00
parent 535c2927b6
commit c52c6c66db
2 changed files with 4 additions and 3 deletions

View file

@ -300,8 +300,9 @@ public class DataOutputStream extends FilterOutputStream implements DataOutput {
int len = s.length();
for (int i = 0 ; i < len ; i++) {
int v = s.charAt(i);
out.write((v >>> 8) & 0xFF);
out.write((v >>> 0) & 0xFF);
writeBuffer[0] = (byte)(v >>> 8);
writeBuffer[1] = (byte)(v >>> 0);
out.write(writeBuffer, 0, 2);
}
incCount(len * 2);
}