-
Notifications
You must be signed in to change notification settings - Fork 15.1k
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
refactor: constexpr lookup tables #38771
Conversation
Does |
It doesn't have the same kind of compile-time-vs-heap-allocations benefits as the previous PR that replaced One good example is applying this approach to I wouldn't expect that level of benefit everywhere, e.g. in code that has fewer comparisons such as the |
No Release Notes |
I was unable to backport this PR to "25-x-y" cleanly; |
I have automatically backported this PR to "26-x-y", please check out #38797 |
* refactor: use a constexpr lookup table in GetPathConstant() * refactor: use a constexpr lookup table in SystemPreferences::GetColor() * refactor: use a constexpr lookup table in SimpleURLLoaderWrapper::Create()
* refactor: use a constexpr lookup table in GetPathConstant() * refactor: use a constexpr lookup table in SystemPreferences::GetColor() * refactor: use a constexpr lookup table in SimpleURLLoaderWrapper::Create() Co-authored-by: Charles Kerr <charles@charleskerr.com>
* refactor: use a constexpr lookup table in GetPathConstant() * refactor: use a constexpr lookup table in SystemPreferences::GetColor() * refactor: use a constexpr lookup table in SimpleURLLoaderWrapper::Create()
* refactor: constexpr lookup tables (#38771) * refactor: use a constexpr lookup table in GetPathConstant() * refactor: use a constexpr lookup table in SystemPreferences::GetColor() * refactor: use a constexpr lookup table in SimpleURLLoaderWrapper::Create() Co-authored-by: Charles Kerr <charles@charleskerr.com> * fix: use MakeFixedFlatMap() instead of MakeFixedFlatMapSorted() The latter compiles faster but does not exist in 24-x-y Xref: https://chromium-review.googlesource.com/c/chromium/src/+/4296340 --------- Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: Charles Kerr <charles@charleskerr.com>
* refactor: use a constexpr lookup table in GetPathConstant() * refactor: use a constexpr lookup table in SystemPreferences::GetColor() * refactor: use a constexpr lookup table in SimpleURLLoaderWrapper::Create()
Description of Change
Use constexpr lookup tables for some of our string-to-value lookups. Uses
base::fixed_flat_map
.Checklist
npm test
passesRelease Notes
Notes: none