3 ms·
You are absolutely right - and the benchmark in the repository doesn't even try to get the value - it's only check for existent of key. However, it can easily
by SoapSeller 10y ago
You are absolutely right - and the benchmark in the repository doesn't even try to get the value - it's only check for existent of key.
However, it can easily be fixed by using something like vector<tuple<string, types_t>> and supplying predicates for both std::sort and std::lower_bound to only consider the first element in the tuple. There will be some performance hit, but should be minimal.
- toth 10y agoI see, that makes sense. I guess at that point you have something very much like std::map, except it doesn't keep itself sorted, you have to do it yourself. I guess for cases like this where you initialize it once and never change it again it could even be a better choice (i.e., faster initialization).
- AstralStorm 10y agoThe main difference is that map cannot be reserved ahead of time.