rostamn739
rostamn739

Reputation: 421

Dictionary access optimization describen - does it take place anywhere?

Most of us compiler nerds have read Google's paper on V8 object property access where the resulting technique is just (in-)directly accessing an array member. My question is:

Does anyone optimize the dictionary access the same way (assigning a fixed index to a (compile time) fixed key)? It doesn't have to be applicable everywhere but perhaps when it's compilation-unit wide? Or the dictionary is readonly? Or between the compilation units at a pass? Whatever, maybe even unrolling the dict. access or inlineing it using a fixed array index instead of a key.

I do know how constant time lookup dictionaries work, but maybe the proposed optimization takes place to further boost the compiled languages (e.g. C++) where the hardware is coached to deal with V-table-like structures at runtime.

Please, if you know any of that, give me a hunch. Thank you much!

TL;DR I want to know of an existing way to optimize dictionary access, (e.g. accessing std::map via array index), not of internal struct/object arrangment in a particular language

Upvotes: 2

Views: 162

Answers (1)

Matthieu M.
Matthieu M.

Reputation: 300149

Doubtful

While this could in theory be possible (being that std::map implementation is part of the Standard library) I know of no C++ compiler that performs such a trick.

And they do not really have to: if you want array indexing in C++, you pick an array and index it (possibly with named constants).

Upvotes: 1

Related Questions