diff options
author | Kulikov Alexey <kulikov.alexey90@gmail.com> | 2019-02-26 05:45:29 +0700 |
---|---|---|
committer | Wouter van Oortmerssen <aardappel@gmail.com> | 2019-02-25 23:45:29 +0100 |
commit | 4e5152d886de963162ae81282240bc5377fa10ce (patch) | |
tree | b61e9ae17778f1449bcb2a81f46c63fa9bd798e0 /tests/MyGame/Example/Stat.java | |
parent | dc61512f20c034a3b949a9e5dfc06ec448a05f20 (diff) | |
download | flatbuffers-4e5152d886de963162ae81282240bc5377fa10ce.tar.gz flatbuffers-4e5152d886de963162ae81282240bc5377fa10ce.tar.bz2 flatbuffers-4e5152d886de963162ae81282240bc5377fa10ce.zip |
Java: Calculation of vtable and vtable size moved to the __init method. (#5210)
vtable and vtable size depends only on `Table#bb_pos` but calculated in
`Table#_offset` method on each field lookup.
Doing this with every call of `Table#__offset` is redundant.
These values can be read once with change of `Table#bb_pos` and reused
for any field lookup.
Diffstat (limited to 'tests/MyGame/Example/Stat.java')
-rw-r--r-- | tests/MyGame/Example/Stat.java | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/tests/MyGame/Example/Stat.java b/tests/MyGame/Example/Stat.java index 73e2bc8f..c995eb1e 100644 --- a/tests/MyGame/Example/Stat.java +++ b/tests/MyGame/Example/Stat.java @@ -11,7 +11,7 @@ import com.google.flatbuffers.*; public final class Stat extends Table { public static Stat getRootAsStat(ByteBuffer _bb) { return getRootAsStat(_bb, new Stat()); } public static Stat getRootAsStat(ByteBuffer _bb, Stat obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)); } - public void __init(int _i, ByteBuffer _bb) { bb_pos = _i; bb = _bb; } + public void __init(int _i, ByteBuffer _bb) { bb_pos = _i; bb = _bb; vtable_start = bb_pos - bb.getInt(bb_pos); vtable_size = bb.getShort(vtable_start); } public Stat __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; } public String id() { int o = __offset(4); return o != 0 ? __string(o + bb_pos) : null; } |