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

Simplify control flow in _Traits_find_MEOW_not_of #5006

Merged
merged 11 commits into from
Oct 12, 2024

Conversation

StephanTLavavej
Copy link
Member

@StephanTLavavej StephanTLavavej commented Oct 10, 2024

This simplifies _Traits_find_first_not_of and _Traits_find_last_not_of, following the patterns in #4744 and #4934, which will make them easier to understand and easier to add vectorized codepaths. These are lossless transformations that don't affect behavior.

  • Replace unnecessarily confusing breaks with immediate returns.
  • Add a return instead of relying on fall-through.
    • This will simplify the following transformation.
  • Flip !_Matches._Mark tests.
    • Both sides unconditionally return, allowing us to flip them. (One case is a forever loop where the only ways out are returns.)
  • Transform "call self with _Special=false" to fall-through.
  • Extract _Elem.
  • Extract _Hay_start, _Hay_end.
  • Fuse bool _Special into its usage.

Except in `_Traits_find_last_of`, which is being changed by GH 4934.
This will simplify the following transformation.
Both sides unconditionally return, allowing us to flip them. (One case is a forever loop where the only ways out are returns.)
@StephanTLavavej StephanTLavavej added the enhancement Something can be improved label Oct 10, 2024
@StephanTLavavej StephanTLavavej requested a review from a team as a code owner October 10, 2024 03:51
AlexGuteniev

This comment was marked as resolved.

@StephanTLavavej

This comment was marked as resolved.

In `_Traits_meow` functions with `if (condition) { woof; } return;` where `woof` is a `for` containing at least two `if`s.
Copy link
Member

@CaseyCarter CaseyCarter left a comment

Choose a reason for hiding this comment

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

This is such a nice simplification, I thought I'd push another commit to do some early-return outdenting.

stl/inc/__msvc_string_view.hpp Outdated Show resolved Hide resolved
stl/inc/__msvc_string_view.hpp Outdated Show resolved Hide resolved
stl/inc/__msvc_string_view.hpp Outdated Show resolved Hide resolved
stl/inc/__msvc_string_view.hpp Outdated Show resolved Hide resolved
stl/inc/__msvc_string_view.hpp Outdated Show resolved Hide resolved
@CaseyCarter CaseyCarter removed their assignment Oct 10, 2024
... to avoid merge conflicts with microsoftGH-4934.

This partially reverts commit 8d902d9.
These return statements are never reached.
@StephanTLavavej
Copy link
Member Author

😻 Looks purr to me!

@StephanTLavavej StephanTLavavej self-assigned this Oct 11, 2024
@StephanTLavavej
Copy link
Member Author

I'm mirroring this to the MSVC-internal repo - please notify me if any further changes are pushed.

@CaseyCarter
Copy link
Member

A merge conflict? Couldn't be me.

@StephanTLavavej
Copy link
Member Author

Remember, I named you Casey "Conflict" Carter via office post-it note almost a decade ago! 🎯 💯 🔮

@StephanTLavavej StephanTLavavej merged commit 926d458 into microsoft:main Oct 12, 2024
39 checks passed
@StephanTLavavej StephanTLavavej deleted the transform-find-meow-of branch October 12, 2024 12:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Something can be improved
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants