Skip to content

codecvt: no conversion for all char-like types of size 1. - #2739

Merged
Stephan T. Lavavej (StephanTLavavej) merged 10 commits into
microsoft:mainfrom
fsb4000:fix2109
Jun 2, 2022
Merged

Stephan T. Lavavej (StephanTLavavej) merged 10 commits into
microsoft:mainfrom
fsb4000:fix2109

Conversation

@fsb4000

Copy link
Copy Markdown
Contributor

Fixes #2109
Fixes #817

@fsb4000
Igor Zhukov (fsb4000) requested a review from a team as a code owner May 25, 2022 11:28
@fsb4000

Copy link
Copy Markdown
Contributor Author
template <class>
_INLINE_VAR constexpr bool test = false;

template <>
_INLINE_VAR constexpr bool test<char> = true;

in two different cpp files gives fatal error LNK1169: one or more multiply defined symbols found with clang-cl and C++14.

Fortunately, there is no code like this in the STL.

Ordinary constexpr variables or constexpr templates variables without explicit specialization work fine.

@CaseyCarter Casey Carter (CaseyCarter) added bug Something isn't working performance Must go faster and removed bug Something isn't working labels May 25, 2022
Comment thread stl/inc/xlocale Outdated
Igor Zhukov (fsb4000) and others added 2 commits May 26, 2022 13:28
Co-authored-by: Alex Guteniev 
@fsb4000

Igor Zhukov (fsb4000) commented May 26, 2022 •

Copy link
Copy Markdown
Contributor Author

Do we need remove_cv_t<_Ty> like there?:

STL/stl/inc/xtr1common

Lines 174 to 180 in 60decd0

template
_INLINE_VAR constexpr bool is_integral_v = _Is_any_of_v, bool, char, signed char, unsigned char,
wchar_t,
#ifdef __cpp_char8_t
char8_t,
#endif // __cpp_char8_t
char16_t, char32_t, short, unsigned short, int, unsigned int, long, unsigned long, long long, unsigned long long>;

@StephanTLavavej

Copy link
Copy Markdown
Member

The type traits for the "primary type categories" like is_integral_v are required to ignore top-level cv-qualifiers (WG21-N4910 [meta.unary.cat]/2). Our internal type traits don't always remove_cv_t, but we need to keep this in mind whenever we're using them, as this is a potential source of bugs.

(_Is_any_of_v itself should not remove_cv_t as it is a generalized is_same which must care about cv-qualifiers; it's things like the "is it safe to activate the memmeow() optimization" helpers that sometimes expect usage to have already removed cv.)

strega-nil-ms
nicole mazzuca (strega-nil-ms) approved these changes May 31, 2022 •
Comment thread stl/inc/xlocale

template
_INLINE_VAR constexpr bool _Is_codecvt_do_always_noconv_v =
is_same_v<_Byte, _Elem> || (_Is_one_byte_char_like_v<_Byte> && _Is_one_byte_char_like_v<_Elem>);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It might be nice to also check for _Is_two_byte_char_like_v, for wchar_t/char16_t?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes, there is an issue for that: #605 (comment)
but I have not yet explored what needs to be done there to speed up

@StephanTLavavej

Copy link
Copy Markdown
Member

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

@StephanTLavavej
Stephan T. Lavavej (StephanTLavavej) merged commit a3c1eb2 into microsoft:main Jun 2, 2022
@StephanTLavavej

Copy link
Copy Markdown
Member

Thanks for this major performance improvement! 🚀 🐇 🏎️

@fsb4000
Igor Zhukov (fsb4000) deleted the fix2109 branch June 2, 2022 04:15
Igor Zhukov (fsb4000) added a commit to fsb4000/STL that referenced this pull request Aug 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

performance Must go faster

Projects

None yet

Development

Successfully merging this pull request may close these issues.

: Performance issue when reading a binary file using std::basic_ifstream : Non-char types are 30 to 50x slower when reading/writing than regular char

5 participants