[libcxx-commits] [libcxx] r356512 - [libc++] Speed up certain locale functions on Windows
Thomas Anderson via libcxx-commits
libcxx-commits at lists.llvm.org
Tue Mar 19 13:30:58 PDT 2019
Author: thomasanderson
Date: Tue Mar 19 13:30:58 2019
New Revision: 356512
URL: http://llvm.org/viewvc/llvm-project?rev=356512&view=rev
Log:
[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
Modified:
libcxx/trunk/src/support/win32/locale_win32.cpp
Modified: libcxx/trunk/src/support/win32/locale_win32.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/support/win32/locale_win32.cpp?rev=356512&r1=356511&r2=356512&view=diff
==============================================================================
--- libcxx/trunk/src/support/win32/locale_win32.cpp (original)
+++ libcxx/trunk/src/support/win32/locale_win32.cpp Tue Mar 19 13:30:58 2019
@@ -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;
}
More information about the libcxx-commits
mailing list