mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-02 04:04:19 +00:00
UnpackTo copies vector elements one-by-one, which can be very inefficient depending on the quality of the compiler optimizations performed. This change updates the operation for vectors of bytes that aren't enums to use 'std::copy', which is usually highly optimized. vectors of types that are more than one byte can't be optimized in this way because of the endianness of the serialized bytes vs. the target architecture endianness. vectors of enums can't be optimized because they are required to be static_cast into the appropriate enum type when stored in the vector. vectors of bools can be optimized in most cases, but since the standard allows std::vector<bool> template specialization for space-savings, std::copy doesn't work on every implementation (looking at you Microsoft). Thus, this optimization is skipped for vector<bool>. For a specific example, this improves the latency of unpacking large buffers on the Hexagon DSP by about 10x. Co-authored-by: Matthew Markwell <markwell@google.com>