benjist benjist - 14 days ago 5
C++ Question

original_order and Arrays in FlatBuffers

The documentation says about original_order:

"original_order (on a table): since elements in a table do not need to be stored in any particular order, they are often optimized for space by sorting them to size. This attribute stops that from happening."

I'm a bit confused now. I considered FlatBuffers tables to be similar to arrays in C++, and in my code I didn't see any issue. For example, I define a LineString geometry like this:

table Vec2List {
p:[Vec2];
}

table Linestring {
points:Vec2List;
}


That works. Though is it required to declare original_order?

Source: https://google.github.io/flatbuffers/md__schemas.html

Answer

You don't need original_order. original_order affects the order of fields in a table. Your tables have only one field, so it would have no effect anyway. Vectors are never affected. I forgot why we even have that flag, there is no use for it under normal circumstances.