mirror of
https://github.com/corda/corda.git
synced 2025-01-19 11:16:54 +00:00
ObjectOutputStream: optimize String serialization
The serialization protocol specifies a quick method to serialize a String (because that is so common an operation): TC_STRING + (short)length + bytes. Let's use that, also to make it easier to test the upcoming changes to TreeMap harmonizing that Avian's serialization of said class with OpenJDK's. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
This commit is contained in:
parent
bba0d25ba5
commit
f3189bc79d
@ -284,6 +284,13 @@ public class ObjectOutputStream extends OutputStream implements DataOutput {
|
||||
rawByte(TC_NULL);
|
||||
return;
|
||||
}
|
||||
if (o instanceof String) {
|
||||
byte[] bytes = ((String)o).getBytes("UTF-8");
|
||||
rawByte(TC_STRING);
|
||||
rawShort(bytes.length);
|
||||
write(bytes);
|
||||
return;
|
||||
}
|
||||
rawByte(TC_OBJECT);
|
||||
classDesc(o.getClass());
|
||||
for (Field field : getFields(o.getClass())) {
|
||||
|
Loading…
Reference in New Issue
Block a user