mirror of
https://github.com/google/flatbuffers.git
synced 2026-07-01 16:13:57 +00:00
[FlexBuffers][Java] Cache size of Sized objects in FlexBuffers (#5551)
In my benchmarks it shows deserialization performance improvements of around 7%
This commit is contained in:
committed by
Wouter van Oortmerssen
parent
d4cae0a623
commit
842f672baf
@@ -635,12 +635,16 @@ public class FlexBuffers {
|
|||||||
|
|
||||||
// Stores size in `byte_width_` bytes before end position.
|
// Stores size in `byte_width_` bytes before end position.
|
||||||
private static abstract class Sized extends Object {
|
private static abstract class Sized extends Object {
|
||||||
|
|
||||||
|
private final int size;
|
||||||
|
|
||||||
Sized(ByteBuffer buff, int end, int byteWidth) {
|
Sized(ByteBuffer buff, int end, int byteWidth) {
|
||||||
super(buff, end, byteWidth);
|
super(buff, end, byteWidth);
|
||||||
|
size = readInt(bb, end - byteWidth, byteWidth);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int size() {
|
public int size() {
|
||||||
return readInt(bb, end - byteWidth, byteWidth);
|
return size;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user