3 ms·
I liked the article, but I didn't understand the meaning of this paragraph: > The string map< occurs 588 times in the WED code base. set< occurs 822 times! A
by gnuvince 12y ago
I liked the article, but I didn't understand the meaning of this paragraph:
> The string map< occurs 588 times in the WED code base. set< occurs 822 times! Approximately 100% of this code is running a lot slower than it could be. This performance problem is the cumulative result of using slow-constant-time coding techniques for years.
Why does 100% of this code run slower than it could? Maps and sets give you quick inserts and lookups, which arrays don't. Without knowing the context in which these 1400-odd structures are used, how can we really know that they're not the proper choice?
- ynik 12y agostd::map and std::set are designed to support a large set of use cases, and as a result, cannot really be optimized. In particular, the iterator invalidation semantics prevent implementers from using more cache-friendly data structures like B-trees.