Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce til::presorted_static_map #7640

Merged
4 commits merged into from
Sep 29, 2020
Merged

Introduce til::presorted_static_map #7640

4 commits merged into from
Sep 29, 2020

Commits on Sep 15, 2020

  1. Introduce til::presorted_static_map

    til::static_map can't be constexpr until we move to C++20.
    It can't be constexpr because std::sort isn't constexpr until then.
    This poses a problem: if we start using it and treating it like a map,
    we'll incur a potentially high cost in static initialization in both
    code size in .text and runtime.
    
    This commit introduces presorted_static_map, which is static_map except
    that it doesn't automatically sort its keys. That's the only difference.
    
    At this point, it's just a maplike interface to a constant array of
    pairs that does a binary search. It should be used for small tables that
    are used infrequently enough as to not warrant their cost in code size
    or initialization time. It should also be used for tables that aren't
    going to be edited much by developers (like the color table in #7578.)
    DHowett committed Sep 15, 2020
    1 Configuration menu
    Copy the full SHA
    0cd8b8e View commit details
    Browse the repository at this point in the history
  2. meh, spe3ll it right

    DHowett committed Sep 15, 2020
    Configuration menu
    Copy the full SHA
    084d006 View commit details
    Browse the repository at this point in the history
  3. code format

    DHowett committed Sep 15, 2020
    Configuration menu
    Copy the full SHA
    5039858 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    23cd8eb View commit details
    Browse the repository at this point in the history