]> Savannah Git Hosting - gnulib.git/commitdiff
uchar-c23: Optimize clearing an mbstate_t.
authorBruno Haible <bruno@clisp.org>
Sun, 16 Jul 2023 05:30:59 +0000 (07:30 +0200)
committerBruno Haible <bruno@clisp.org>
Sun, 16 Jul 2023 08:29:19 +0000 (10:29 +0200)
* lib/lc-charset-unicode.c (locale_encoding_to_unicode,
unicode_to_locale_encoding): Use mbszero.
* modules/uchar-c23 (Depends-on): Add mbszero.

ChangeLog
lib/lc-charset-unicode.c
modules/uchar-c23

index 7371228547dcb14cfca217717f4bf7dfd238e36e..567c971b6fb8ad6bbcbacbd9830d22d54769d988 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2023-07-16  Bruno Haible  <bruno@clisp.org>
+
+       uchar-c23: Optimize clearing an mbstate_t.
+       * lib/lc-charset-unicode.c (locale_encoding_to_unicode,
+       unicode_to_locale_encoding): Use mbszero.
+       * modules/uchar-c23 (Depends-on): Add mbszero.
+
 2023-07-16  Bruno Haible  <bruno@clisp.org>
 
        quotearg: Optimize clearing an mbstate_t.
index afbc188ad7d76b2996c3b622ec8181982955a544..20994618b41c0dbecb55538818b8bad8cc3dde5d 100644 (file)
@@ -158,7 +158,8 @@ locale_encoding_to_unicode (wchar_t wc)
   char mbbuf[64];
   size_t mbcnt;
   {
-    mbstate_t state = { 0 };
+    mbstate_t state;
+    mbszero (&state);
     mbcnt = wcrtomb (mbbuf, wc, &state);
     if (mbcnt > sizeof (mbbuf))
       /* wcrtomb did not recognize the wide character wc.  */
@@ -248,7 +249,8 @@ unicode_to_locale_encoding (char32_t uc)
 
   wchar_t wc;
   {
-    mbstate_t state = { 0 };
+    mbstate_t state;
+    mbszero (&state);
     if (mbrtowc (&wc, mbbuf, mbcnt, &state) != mbcnt)
       /* iconv produced an invalid multibyte sequence.  */
       return 0;
index 11e08652cb9bc45f5c4885616d752ad2cde41a87..5fcd2802bf3abeba700e5b2c4c4414d07a954726 100644 (file)
@@ -13,6 +13,7 @@ localcharset
 streq
 lock
 tls
+mbszero
 wcrtomb
 unistr/u8-mbtouc
 unistr/u8-uctomb