Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@StephanTLavavej
Copy link
Member

Works towards #189.

Commits

  • Drop __CRTDECL on internal header-only functions.
    • Replaced: __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. (<vcruntime.h> defines __CRTDECL to be __CLRCALL_PURE_OR_CDECL.)
  • Unify with if constexpr, part 1: _LStrcoll()
  • Unify with if constexpr, part 2: _LStrxfrm()
  • Unify with if constexpr, part 3: _Maklocbyte, _Maklocchr, _Maklocstr
  • Fix bogus SAL annotations on _Strxfrm(), _Wcsxfrm(), and _LStrxfrm(), following <regex>: regex_traits::transform_primary should yield primary sort keys appropriate for the imbued locale #5444.
  • Fix comment: _XStrxfrm (no such thing) => _LStrxfrm
  • _Maklocbyte, _Maklocchr, _Maklocstr: Guard unsigned short with #ifdef _CRTBLD.
  • Pass an explicit template arg to _Maklocchr and _Maklocstr instead 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.
  • Unify wchar_t and unsigned short, part 1: Prepare _Maklocstr
  • Unify wchar_t and unsigned short, part 2: Prepare _Maklocbyte, _Maklocchr
  • Unify wchar_t and unsigned 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.
    • _Count is unused at this point (and there's no outer loop).
  • _Maklocstr: Improve variable scoping, part 1.
    • _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.
  • _Maklocstr: Improve variable scoping, part 2.
    • _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.
  • Guard locale::_Locimp::_Makeushloc() with #ifdef _CRTBLD.
    • Users with real wchar_t should never see this.

`__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.
…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.
@StephanTLavavej StephanTLavavej requested a review from a team as a code owner December 1, 2025 10:38
@StephanTLavavej StephanTLavavej added the enhancement Something can be improved label Dec 1, 2025
@github-project-automation github-project-automation bot moved this to Initial Review in STL Code Reviews Dec 1, 2025
@StephanTLavavej StephanTLavavej mentioned this pull request Dec 1, 2025
@StephanTLavavej StephanTLavavej moved this from Initial Review to Final Review in STL Code Reviews Dec 1, 2025
@StephanTLavavej
Copy link
Member Author

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

@StephanTLavavej StephanTLavavej moved this from Final Review to Merging in STL Code Reviews Dec 1, 2025
@StephanTLavavej StephanTLavavej merged commit 8557b90 into microsoft:main Dec 1, 2025
45 checks passed
@github-project-automation github-project-automation bot moved this from Merging to Done in STL Code Reviews Dec 1, 2025
@StephanTLavavej StephanTLavavej deleted the unify-locale-helpers branch December 1, 2025 18:35
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