Skip to content

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

Merged
Stephan T. Lavavej (StephanTLavavej) merged 16 commits into
microsoft:mainfrom
AlexGuteniev:tag_dispatch
Oct 20, 2021
Merged

Replace tag dispatch with if constexpr for _Choose_pocca, _Choose_pocma#2217
Stephan T. Lavavej (StephanTLavavej) merged 16 commits into
microsoft:mainfrom
AlexGuteniev:tag_dispatch

Conversation

@AlexGuteniev

Copy link
Copy Markdown
Contributor

Towards #189

@CaseyCarter Casey Carter (CaseyCarter) added the throughput Must compile faster label Sep 26, 2021
@AlexGuteniev Alex Guteniev (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
Alex Guteniev (AlexGuteniev) marked this pull request as ready for review September 26, 2021 17:20
Comment thread stl/inc/deque Outdated
Comment thread stl/inc/deque
Comment thread stl/inc/xstring Outdated

Copy link
Copy Markdown
Member

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.

Comment thread stl/inc/xstring Outdated
Comment thread stl/inc/vector Outdated
Comment thread stl/inc/deque Outdated
Comment thread stl/inc/deque Outdated
Comment thread stl/inc/xhash Outdated
@StephanTLavavej

Copy link
Copy Markdown
Member

FYI Casey Carter (@CaseyCarter), I pushed changes after you approved. As Alex Guteniev (@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
Copy Markdown
Member

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

@StephanTLavavej
Stephan T. Lavavej (StephanTLavavej) merged commit bb210e7 into microsoft:main Oct 20, 2021
@StephanTLavavej

Copy link
Copy Markdown
Member

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

@AlexGuteniev
Alex Guteniev (AlexGuteniev) deleted the tag_dispatch branch October 20, 2021 10:29
AZero13 (AZero13) pushed a commit to AZero13/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.

5 participants