From: Bruno Haible <bruno@clisp.org>
To: bug-gnulib@gnu.org
Subject: localename-unsafe: Optimize
Date: Thu, 15 Feb 2024 22:36:25 +0100 [thread overview]
Message-ID: <4557446.KTMopqUuYO@nimes> (raw)
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 other threads:[~2024-02-15 21:36 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://lists.gnu.org/mailman/listinfo/bug-gnulib
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4557446.KTMopqUuYO@nimes \
--to=bruno@clisp.org \
--cc=bug-gnulib@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).