Skip to content

Conversation

wravery
Copy link
Contributor

@wravery wravery commented May 2, 2022

Fix #139

Unfortunately, constexpr support for std::vector seems to be lagging behind in GCC and AppleClang, so I was only able to do this by extracting some of the lookup logic an templatizing it on the container and iterator types in internal::sorted_map_equal_range and internal::sorted_map_lookup. That way it can apply the same logic to perform lookups against a std::array<std::pair<K, V>> as it would for an internal::sorted_map<K, V>.

The only place where I've actually adopted this is in the generated enum value maps, but this should make looking up an enum value O(log(n)) instead of O(n) at runtime. It also lets you perform compile time mapping between the strings and their enum values.

@wravery wravery merged commit c47cd51 into microsoft:main May 3, 2022
@wravery wravery deleted the constexpr-sorted branch May 3, 2022 00:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

improve static data structures
1 participant