diff options
author | Arne Juul <arnej@yahooinc.com> | 2023-01-19 09:57:19 +0000 |
---|---|---|
committer | Arne Juul <arnej@yahooinc.com> | 2023-01-19 09:57:19 +0000 |
commit | bd93b875ce0eb79c8155730bf8dbbeea9cf27212 (patch) | |
tree | 7828d3f746b05528b9dddf9d76982335923cc26b /document/src/main | |
parent | ffba12c231f17e69dcd3f72edf6308772113fd0a (diff) |
no real need to use a temporary buffer
Diffstat (limited to 'document/src/main')
-rw-r--r-- | document/src/main/java/com/yahoo/document/serialization/VespaDocumentDeserializer6.java | 31 |
1 files changed, 6 insertions, 25 deletions
diff --git a/document/src/main/java/com/yahoo/document/serialization/VespaDocumentDeserializer6.java b/document/src/main/java/com/yahoo/document/serialization/VespaDocumentDeserializer6.java index a9c3d4804a1..e37d579a0a7 100644 --- a/document/src/main/java/com/yahoo/document/serialization/VespaDocumentDeserializer6.java +++ b/document/src/main/java/com/yahoo/document/serialization/VespaDocumentDeserializer6.java @@ -269,15 +269,7 @@ public class VespaDocumentDeserializer6 extends BufferSerializer implements Docu fieldIdsAndLengths.add(new Tuple2<>(getInt1_4Bytes(null), getInt2_4_8Bytes(null))); } - // save a reference to the big buffer we're reading from: - GrowableByteBuffer bigBuf = buf; - GrowableByteBuffer thisStructOnly = GrowableByteBuffer.wrap(getBuf().array(), position(), dataSize); - // set position in original buffer to after data - position(position() + dataSize); - - // for a while: deserialize from this buffer instead: - buf = thisStructOnly; - + int afterPos = position() + dataSize; s.clear(); StructDataType type = s.getDataType(); for (int i=0; i<numberOfFields; ++i) { @@ -294,9 +286,8 @@ public class VespaDocumentDeserializer6 extends BufferSerializer implements Docu position(posBefore + fieldIdsAndLengths.get(i).second.intValue()); } } - - // restore the original buffer - buf = bigBuf; + // set position to after data + position(afterPos); } private void readHeaderBody(Document target) { @@ -315,16 +306,7 @@ public class VespaDocumentDeserializer6 extends BufferSerializer implements Docu fieldIdsAndLengths.add(new Tuple2<>(getInt1_4Bytes(null), getInt2_4_8Bytes(null))); } - // save a reference to the big buffer we're reading from: - GrowableByteBuffer bigBuf = buf; - GrowableByteBuffer thisStructOnly = GrowableByteBuffer.wrap(getBuf().array(), position(), dataSize); - - // set position in original buffer to after data - position(position() + dataSize); - - // for a while: deserialize from this buffer instead: - buf = thisStructOnly; - + int afterPos = position() + dataSize; StructDataType priType = target.getDataType().contentStruct(); for (int i=0; i<numberOfFields; ++i) { @@ -339,9 +321,8 @@ public class VespaDocumentDeserializer6 extends BufferSerializer implements Docu //jump to beginning of next field: position(posBefore + fieldIdsAndLengths.get(i).second.intValue()); } - - // restore the original buffer - buf = bigBuf; + // set position to after data + position(afterPos); } public void read(FieldBase field, StructuredFieldValue value) { |