Skip to content

Conversation

frederick-vs-ja
Copy link
Contributor

Currently, both _Allocate and _Deallocate have multiple overloads that are dispatched by SFINAE.
It seems that we should dispatch overaligned and normal branches with if constexpr instead (see #189).

@frederick-vs-ja frederick-vs-ja requested a review from a team as a code owner March 2, 2024 15:32
@StephanTLavavej StephanTLavavej added the enhancement Something can be improved label Mar 2, 2024
@StephanTLavavej StephanTLavavej self-assigned this Mar 2, 2024
When `_Bytes == 0`, the branch `_Bytes >= _Big_allocation_threshold` will certainly not be taken, so we can perform this transformation.
This transformation has very minor impact. Sometimes, we'll call `is_constant_evaluated` when we would have returned `_Traits::_Allocate(_Bytes)` anyways. (This happens when we don't take the high-`_Align` branch and we aren't x86/x64.) This is an extremely minor cost, and it completely vanishes in release mode. The code simplicity is well worth it.
@StephanTLavavej
Copy link
Member

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

@StephanTLavavej
Copy link
Member

I've pushed a merge with main to resolve a trivial adjacent-delete conflict in <xmemory>.

@StephanTLavavej StephanTLavavej merged commit ddc5a62 into microsoft:main Mar 8, 2024
@StephanTLavavej
Copy link
Member

Thanks for this dramatic simplification! All shall love if constexpr and despair! 🧝‍♀️ 👸 💍

@frederick-vs-ja frederick-vs-ja deleted the aligned-branches branch March 8, 2024 02:42
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.

2 participants