-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Unify locale helpers with if constexpr
#5923
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
Merged
StephanTLavavej
merged 15 commits into
microsoft:main
from
StephanTLavavej:unify-locale-helpers
Dec 1, 2025
Merged
Unify locale helpers with if constexpr
#5923
StephanTLavavej
merged 15 commits into
microsoft:main
from
StephanTLavavej:unify-locale-helpers
Dec 1, 2025
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
`__CRTDECL (_LStr(coll|xfrm)|_Makloc(byte|chr|str)|_Getloctxt)` => `$1` These functions aren't dllexported or address-taken, so their calling convention doesn't matter.
…rm()`, following GH 5444.
…h `#ifdef _CRTBLD`. This follows `_LStrcoll` and `_LStrxfrm`, changed by GH 5361.
…d of a typed null pointer. This is fine because it can't be deduced now. These are header-only (and aren't `extern "C"`) and their signatures are changing, so we don't need to rename them.
…rtbld_ushort`. `remove_cv_t<_Elem>` is currently unnecessary, but it makes me feel better to have type traits that behave like the primary type categories.
`_Count` is unused at this point (and there's no outer loop).
`_Count` can be scoped to the for-loop. `_Count1` can be const. `_Wchars` and `_Ptr1` can be initialized when defined, instead of assigned at the beginning of the for-loop.
`_Bytes` doesn't communicate information across loops or loop iterations. It's always assigned to in the loop body, then read from at the end of the iteration. Making it a const local in each loop iteration is significantly clearer.
Users with real wchar_t should never see this.
Merged
Member
Author
|
I'm mirroring this to the MSVC-internal repo - please notify me if any further changes are pushed. |
zacklj89
approved these changes
Dec 1, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Works towards #189.
Commits
__CRTDECLon internal header-only functions.__CRTDECL (_LStr(coll|xfrm)|_Makloc(byte|chr|str)|_Getloctxt)=>$1<vcruntime.h>defines__CRTDECLto be__CLRCALL_PURE_OR_CDECL.)if constexpr, part 1:_LStrcoll()if constexpr, part 2:_LStrxfrm()if constexpr, part 3:_Maklocbyte,_Maklocchr,_Maklocstr_Strxfrm(),_Wcsxfrm(), and_LStrxfrm(), following<regex>:regex_traits::transform_primaryshould yield primary sort keys appropriate for the imbued locale #5444._XStrxfrm(no such thing) =>_LStrxfrm_Maklocbyte,_Maklocchr,_Maklocstr: Guardunsigned shortwith#ifdef _CRTBLD._LStrcolland_LStrxfrm, changed by<locale>: Repairstd::collate<unsigned short>#5361.codecvt<unsigned short, char, mbstate_t>andctype<unsigned short>as the only exceptions; I currently don't understand what's going on with them._Maklocchrand_Maklocstrinstead of a typed null pointer.extern "C") and their signatures are changing, so we don't need to rename them.wchar_tandunsigned short, part 1: Prepare_Maklocstrwchar_tandunsigned short, part 2: Prepare_Maklocbyte,_Maklocchrwchar_tandunsigned short, part 3: Extract_Is_wchar_or_crtbld_ushort.remove_cv_t<_Elem>is currently unnecessary, but it makes me feel better to have type traits that behave like the primary type categories._Maklocstr: Remove dead_Count -= _Bytes._Countis unused at this point (and there's no outer loop)._Maklocstr: Improve variable scoping, part 1._Countcan be scoped to the for-loop._Count1can be const._Wcharsand_Ptr1can be initialized when defined, instead of assigned at the beginning of the for-loop._Maklocstr: Improve variable scoping, part 2._Bytesdoesn't communicate information across loops or loop iterations. It's always assigned to in the loop body, then read from at the end of the iteration. Making it a const local in each loop iteration is significantly clearer.locale::_Locimp::_Makeushloc()with#ifdef _CRTBLD.wchar_tshould never see this.