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

vector_algorithms.cpp: clearer control flow in bitset::to_string #4490

Merged
merged 1 commit into from Mar 21, 2024

Conversation

AlexGuteniev
Copy link
Contributor

Use else instead of early return

@AlexGuteniev AlexGuteniev requested a review from a team as a code owner March 19, 2024 12:30
@StephanTLavavej StephanTLavavej added enhancement Something can be improved decision needed We need to choose something before working on this labels Mar 19, 2024
@StephanTLavavej StephanTLavavej self-assigned this Mar 19, 2024
@StephanTLavavej
Copy link
Member

Is this clearer? I need to think about whether the finality of an early return is better than chaining.

@AlexGuteniev
Copy link
Contributor Author

It now stands out so that it is clear that it is only a fallbaxk, and not tail handling

@jovibor
Copy link
Contributor

jovibor commented Mar 19, 2024

Honestly, it's more of a personal preference than anything.
Also, this construct:

    } else
#endif // !defined(_M_ARM64EC)

looks clunky. (else immediately following by endif)

@StephanTLavavej
Copy link
Member

@AlexGuteniev Hmm, I suppose it's at least equally clear.

@jovibor It looks weird, but we've increasingly used this pattern when we need to interleave preprocessor conditions with if constexpr or runtime if control flow. I have to imagine both preprocessor situations in sequence when reasoning about such code, but as long as the interleaving isn't too tangled, it ends up being reasonably readable.

@StephanTLavavej StephanTLavavej removed the decision needed We need to choose something before working on this label Mar 20, 2024
@StephanTLavavej
Copy link
Member

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

@StephanTLavavej StephanTLavavej merged commit 15bccea into microsoft:main Mar 21, 2024
35 checks passed
@StephanTLavavej
Copy link
Member

🧹 👓 ✨

@AlexGuteniev AlexGuteniev deleted the else branch March 21, 2024 22:07
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.

None yet

3 participants