diff options
author | Thomas Anderson <thomasanderson@google.com> | 2019-03-19 20:30:58 +0000 |
---|---|---|
committer | Thomas Anderson <thomasanderson@google.com> | 2019-03-19 20:30:58 +0000 |
commit | a0feccdf5692389920206444aea6b34105554c7f (patch) | |
tree | 2b7c6c4d5c5d57369df298c33206dec634bf6e97 /libcxx/src/support | |
parent | de548ccab9f1dfdefff338754fbc151f4b5cee46 (diff) | |
download | bcm5719-llvm-a0feccdf5692389920206444aea6b34105554c7f.tar.gz bcm5719-llvm-a0feccdf5692389920206444aea6b34105554c7f.zip |
[libc++] Speed up certain locale functions on Windows
The issue is that __libcpp_locale_guard makes some slow calls to setlocale().
This change avoids using __libcpp_locale_guard in snprintf_l().
Fixes https://bugs.llvm.org/show_bug.cgi?id=41131
Differential Revision: https://reviews.llvm.org/D59525
llvm-svn: 356512
Diffstat (limited to 'libcxx/src/support')
-rw-r--r-- | libcxx/src/support/win32/locale_win32.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/libcxx/src/support/win32/locale_win32.cpp b/libcxx/src/support/win32/locale_win32.cpp index c11adfe4cda..d02d7ffc3cd 100644 --- a/libcxx/src/support/win32/locale_win32.cpp +++ b/libcxx/src/support/win32/locale_win32.cpp @@ -87,10 +87,16 @@ int wctob_l( wint_t c, locale_t loc ) int snprintf_l(char *ret, size_t n, locale_t loc, const char *format, ...) { +#if !defined(_LIBCPP_MSVCRT) __libcpp_locale_guard __current(loc); +#endif va_list ap; va_start( ap, format ); +#if defined(_LIBCPP_MSVCRT) + int result = _vsnprintf_l( ret, n, format, loc, ap ); +#else int result = vsnprintf( ret, n, format, ap ); +#endif va_end(ap); return result; } |