Skip to content

Commit 330b197

Browse files
authored
Avoid calling setlocale in do_unshift when unnecessary
1 parent af641ff commit 330b197

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

libcxx/src/locale.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1475,6 +1475,8 @@ codecvt<wchar_t, char, mbstate_t>::result codecvt<wchar_t, char, mbstate_t>::do_
14751475
codecvt<wchar_t, char, mbstate_t>::result codecvt<wchar_t, char, mbstate_t>::do_unshift(
14761476
state_type& st, extern_type* to, extern_type* to_end, extern_type*& to_nxt) const {
14771477
to_nxt = to;
1478+
if (std::mbsinit(&st))
1479+
return ok;
14781480
extern_type tmp[MB_LEN_MAX];
14791481
size_t n = __locale::__wcrtomb(tmp, intern_type(), &st, __l_);
14801482
if (n == size_t(-1) || n == 0) // on error

0 commit comments

Comments
 (0)