bug-gnulib@gnu.org mirror (unofficial)
 help / color / mirror / Atom feed
From: Bruno Haible <bruno@clisp.org>
To: bug-gnulib@gnu.org
Subject: nstrftime, fprintftime: Optimize
Date: Thu, 15 Feb 2024 22:38:38 +0100	[thread overview]
Message-ID: <8376553.GJh79HuArf@nimes> (raw)

This patch implements another aforementioned optimization: The function
should_remove_ampm uses the locale name directly and stops accessing it
before the function returns.


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

	nstrftime, fprintftime: Optimize.
	* lib/strftime.c (should_remove_ampm): Call gl_locale_name_unsafe
	instead of gl_locale_name.
	* modules/nstrftime (Depends-on): Remove localename. Add
	localename-unsafe.

diff --git a/lib/strftime.c b/lib/strftime.c
index c7256c3d35..128176cad4 100644
--- a/lib/strftime.c
+++ b/lib/strftime.c
@@ -401,7 +401,7 @@ should_remove_ampm (void)
      lt lv mg mhr mi mk mn ms mt nb nds nhn nl nn nr nso oc os pap pl pt ro
      ru rw sah sc se sgs sk sl sm sr ss st su sv szl tg tk tn ts tt ug uk unm
      uz ve wae wo xh zu  */
-  const char *loc = gl_locale_name (LC_TIME, "LC_TIME");
+  const char *loc = gl_locale_name_unsafe (LC_TIME, "LC_TIME");
   bool remove_ampm = false;
   switch (loc[0])
     {
diff --git a/modules/nstrftime b/modules/nstrftime
index 77a8594c4c..c5ab2710c0 100644
--- a/modules/nstrftime
+++ b/modules/nstrftime
@@ -15,7 +15,7 @@ errno
 extensions
 intprops
 libc-config
-localename
+localename-unsafe
 stdbool
 stdckdint
 time_rz





                 reply	other threads:[~2024-02-15 21:38 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=8376553.GJh79HuArf@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).