bug-gnulib@gnu.org mirror (unofficial)
 help / color / mirror / Atom feed
* localename-unsafe: Optimize
@ 2024-02-15 21:36 Bruno Haible
  0 siblings, 0 replies; only message in thread
From: Bruno Haible @ 2024-02-15 21:36 UTC (permalink / raw)
  To: bug-gnulib

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:





^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2024-02-15 21:36 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-15 21:36 localename-unsafe: Optimize Bruno Haible

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).