From a7adefb5337ac617dae143966f563ec325352038 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Sun, 16 Jul 2023 07:30:50 +0200 Subject: [PATCH] mbswidth: Optimize clearing an mbstate_t. * lib/mbswidth.c (mbsnwidth): Use mbszero. * modules/mbswidth (Depends-on): Add mbszero. --- ChangeLog | 6 ++++++ lib/mbswidth.c | 2 +- modules/mbswidth | 1 + 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 946725e139..49d27cc084 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2023-07-16 Bruno Haible + + mbswidth: Optimize clearing an mbstate_t. + * lib/mbswidth.c (mbsnwidth): Use mbszero. + * modules/mbswidth (Depends-on): Add mbszero. + 2023-07-16 Bruno Haible mbfile: Optimize clearing an mbstate_t. diff --git a/lib/mbswidth.c b/lib/mbswidth.c index a1613dcad6..9ce94ae80d 100644 --- a/lib/mbswidth.c +++ b/lib/mbswidth.c @@ -94,7 +94,7 @@ mbsnwidth (const char *string, size_t nbytes, int flags) /* If we have a multibyte sequence, scan it up to its end. */ { mbstate_t mbstate; - memset (&mbstate, 0, sizeof mbstate); + mbszero (&mbstate); for (;;) { char32_t wc; diff --git a/modules/mbswidth b/modules/mbswidth index 4dd8c55ee4..3c2e17dc06 100644 --- a/modules/mbswidth +++ b/modules/mbswidth @@ -13,6 +13,7 @@ wchar uchar mbrtoc32 mbsinit +mbszero c32width c32iscntrl extensions -- 2.39.5