bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

localename-unsafe: Optimize


From: Bruno Haible
Subject: localename-unsafe: Optimize
Date: Thu, 15 Feb 2024 22:36:25 +0100

This patch contains the aforementioned optimization: Call
setlocale_null_unlocked instead of setlocale_null when we know
that it's safe.


2024-02-15  Bruno Haible  <bruno@clisp.org>

        localename-unsafe: Optimize.
        * lib/localename-unsafe.c (gl_locale_name_posix_unsafe): Call
        setlocale_null_unlocked instead of setlocale_null.
        * modules/localename-unsafe (Depends-on): Add setlocale-null-unlocked.

diff --git a/lib/localename-unsafe.c b/lib/localename-unsafe.c
index 5770d4a859..845ee92c31 100644
--- a/lib/localename-unsafe.c
+++ b/lib/localename-unsafe.c
@@ -3265,7 +3265,10 @@ gl_locale_name_posix_unsafe (int category, _GL_UNUSED 
const char *categoryname)
     /* Use the POSIX methods of looking to 'LC_ALL', 'LC_xxx', and 'LANG'.
        On some systems this can be done by the 'setlocale' function itself.  */
 #if defined HAVE_LC_MESSAGES && defined HAVE_LOCALE_NULL
-    locname = setlocale_null (category);
+    /* All platforms for which HAVE_LOCALE_NULL is defined happen to have
+       SETLOCALE_NULL_ONE_MTSAFE defined to 1.  Therefore it is OK, here,
+       to call setlocale_null_unlocked instead of setlocale_null.  */
+    locname = setlocale_null_unlocked (category);
 #else
     /* On other systems we ignore what setlocale reports and instead look at 
the
        environment variables directly.  This is necessary
diff --git a/modules/localename-unsafe b/modules/localename-unsafe
index 3cb38a7c51..4b8ad0279b 100644
--- a/modules/localename-unsafe
+++ b/modules/localename-unsafe
@@ -24,6 +24,7 @@ strdup
 lock
 langinfo
 setlocale-null
+setlocale-null-unlocked
 thread-optim
 
 configure.ac:






reply via email to

[Prev in Thread] Current Thread [Next in Thread]