Commit 842f672b authored by Paulo Pinheiro's avatar Paulo Pinheiro Committed by Wouter van Oortmerssen

[FlexBuffers][Java] Cache size of Sized objects in FlexBuffers (#5551)

In my benchmarks it shows deserialization performance improvements of
around 7%
parent d4cae0a6
......@@ -635,12 +635,16 @@ public class FlexBuffers {
// Stores size in `byte_width_` bytes before end position.
private static abstract class Sized extends Object {
private final int size;
Sized(ByteBuffer buff, int end, int byteWidth) {
super(buff, end, byteWidth);
size = readInt(bb, end - byteWidth, byteWidth);
}
public int size() {
return readInt(bb, end - byteWidth, byteWidth);
return size;
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment