On 9/06/2015 03:01, Anton Bachin wrote:
That’s right, for now I am simply doing a linear scan through an array of strings. Changing the complexity to sub-linear is on my list of things to do, and I’ve considered those approaches (compile-time binary search, hashing, and trie). So far, I’ve been focusing on the interface and generation procedure instead, so I didn’t want to get into too much optimization before I knew exactly what the constraints would be. It’s getting pretty stable now, so I would be grateful for any comments/assistance with compile-time data structures.
Don't forget to measure performance. Given that enums tend to have a very low N, when I made a superficially similar static map with a runtime string index scan it turned out to be faster to just do the linear scan than to try to compute hashes or do more complex searches. (As an aside, it was quite a handy data structure. It was mainly intended for string-to-enum conversions but because of the way it was templated it could be abused to do string-to-member-pointer conversions as well, which enabled all sorts of interesting reflection scenarios.)