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

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

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

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

only message in thread, other threads:[~2024-02-15 21:38 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:38 nstrftime, fprintftime: 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).