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

Replace tag dispatch with if constexpr for _Choose_pocca, _Choose_pocma #2217

Merged
merged 16 commits into from
Oct 20, 2021

Conversation

AlexGuteniev
Copy link
Contributor

Towards #189

@CaseyCarter CaseyCarter added the throughput Must compile faster label Sep 26, 2021
@AlexGuteniev AlexGuteniev changed the title Replace tag dispatch with if constexpr for _Choose_pocca Replace tag dispatch with if constexpr for _Choose_pocca, _Choose_pocma Sep 26, 2021
@AlexGuteniev AlexGuteniev marked this pull request as ready for review September 26, 2021 17:20
@AlexGuteniev AlexGuteniev requested a review from a team as a code owner September 26, 2021 17:20
stl/inc/deque Outdated Show resolved Hide resolved
stl/inc/deque Show resolved Hide resolved
stl/inc/xstring Outdated Show resolved Hide resolved
@CaseyCarter CaseyCarter removed their assignment Oct 5, 2021
@StephanTLavavej StephanTLavavej self-assigned this Oct 13, 2021
Copy link
Member

@StephanTLavavej StephanTLavavej left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I've validated and will push changes.

stl/inc/xstring Outdated Show resolved Hide resolved
stl/inc/vector Outdated Show resolved Hide resolved
stl/inc/deque Outdated Show resolved Hide resolved
stl/inc/deque Outdated Show resolved Hide resolved
stl/inc/xhash Outdated Show resolved Hide resolved
@StephanTLavavej
Copy link
Member

FYI @CaseyCarter, I pushed changes after you approved. As @AlexGuteniev noted, in #2217 (comment) you had asked for <xhash> to be left as-is to avoid unnecessary refactoring (which is greatly appreciated 😻), but after going on vacation and looking at this with a fresh eye, I noticed that the if constexpr modernization is introducing code duplication when before we had centralization with the tag dispatch overloads. I think that for maintainability, this justifies slightly larger changes to preserve code centralization (and follow the pattern in other containers).

The necessary code is a simple guard type, expressed with a const _Hash& since we never need to dismiss it. As I mentioned in #2217 (comment) , the behavioral changes are limited to the STL-internal checks in the test suite, and result in invariants being checked in the event of exceptions (which is totally beneficial).

(We could actually drop the guard type and repeat the invariant checks before every return - which would be less severe than duplicating the actual logic - but I felt that the guards were the simplest.)

Requesting double-final review as these changes are a bit larger than the typical stuff I push.

@StephanTLavavej
Copy link
Member

I'm mirroring this to an MSVC-internal PR; please notify me if any further changes are pushed.

@StephanTLavavej StephanTLavavej merged commit bb210e7 into microsoft:main Oct 20, 2021
@StephanTLavavej
Copy link
Member

Thanks for improving this code - all shall love if constexpr and despair! 😻 🚀 🎉

@AlexGuteniev AlexGuteniev deleted the tag_dispatch branch October 20, 2021 10:29
AreaZR pushed a commit to AreaZR/STL that referenced this pull request Nov 4, 2021
…e_pocma` (microsoft#2217)

Co-authored-by: Stephan T. Lavavej <stl@microsoft.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
throughput Must compile faster
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants
  翻译: