Closed GoogleCodeExporter closed 8 years ago
This issue was closed by revision r299.
Original comment by nathan.s...@gmail.com
on 18 Jun 2012 at 2:37
Output#writeString(String) cannot be changed to
Output#writeString(CharSequence) because the ASCII path needs String#getBytes.
I added Output#writeString(CharSequence) though, which always writes UTF8. This
is slightly faster than writeString(). The value can be read using
Input#readString().
To avoid a new String when reading, I added Input#readStringBuilder(). This is
slightly faster than readString() for UTF8. When reading ASCII written by
writeString() or writeAscii(), readStringBuilder() is slightly slower than
readString(). This isn't much on an issue though, because the most likely case
is to write a StringBuilder and read a StringBuilder. The reason it is slower
is because the readString() ASCII path is very fast by going directly from
bytes to a String. readStringBuilder() can't use bytes, so has to convert to
char[]. I benchmarked converting to char[] versus using readAscii() and the
difference was negligible so I went with the solution that was less code.
Original comment by nathan.s...@gmail.com
on 18 Jun 2012 at 2:37
Great!
Original comment by serverpe...@gmail.com
on 18 Jun 2012 at 5:40
Original issue reported on code.google.com by
serverpe...@gmail.com
on 18 Jun 2012 at 12:49