mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-02 12:05:50 +00:00
The original implementation of map access is very naive: - Encode String to UTF8 byte[] - Creates a new KeyVector - Performs a binary search to find the key - return value So every access to the Map there was useless allocations of Keys and KeyVector and complete encoding of the search key, which for most comparisons would be wasteful. This changes completely removes the use of KeyVector and compute the key positions on the spot. Besides that, it compares keys codepoint-by-codepoint, avoiding unnecessary allocations and reducing encoding for most cases. Some benchmarks result in a 2.75x speedup.
45 KiB
45 KiB