From 898cd2dc647b75f472d69bb1d2d116719725c31c Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Wed, 12 Jul 2023 00:58:51 +0200 Subject: [PATCH] mbsrtoc32s, mbsnrtoc32s: Small optimization. * lib/mbsrtoc32s.c (USES_C32): Set to 0 when the module 'mbrtoc32-regular' is in use. * lib/mbsnrtoc32s.c (USES_C32): Likewise. --- ChangeLog | 7 +++++++ lib/mbsnrtoc32s.c | 8 +++++++- lib/mbsrtoc32s.c | 8 +++++++- 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 22000a4549..e55bfec8ed 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2023-07-11 Bruno Haible + + mbsrtoc32s, mbsnrtoc32s: Small optimization. + * lib/mbsrtoc32s.c (USES_C32): Set to 0 when the module + 'mbrtoc32-regular' is in use. + * lib/mbsnrtoc32s.c (USES_C32): Likewise. + 2023-07-11 Bruno Haible mbswidth: Add a benchmark. diff --git a/lib/mbsnrtoc32s.c b/lib/mbsnrtoc32s.c index 788eadd99e..0377a361d3 100644 --- a/lib/mbsnrtoc32s.c +++ b/lib/mbsnrtoc32s.c @@ -47,7 +47,13 @@ extern mbstate_t _gl_mbsrtoc32s_state; # define DCHAR_T char32_t # define INTERNAL_STATE _gl_mbsrtoc32s_state # define MBRTOWC mbrtoc32 -# define USES_C32 1 +# if GNULIB_MBRTOC32_REGULAR + /* If the 'mbrtoc32-regular' module is in use, we don't need to handle + a (size_t)(-3) return value from mbrtoc32. */ +# define USES_C32 0 +# else +# define USES_C32 1 +# endif # include "mbsnrtowcs-impl.h" #else diff --git a/lib/mbsrtoc32s.c b/lib/mbsrtoc32s.c index 92f7433818..19ec126b5f 100644 --- a/lib/mbsrtoc32s.c +++ b/lib/mbsrtoc32s.c @@ -39,7 +39,13 @@ extern mbstate_t _gl_mbsrtoc32s_state; # define DCHAR_T char32_t # define INTERNAL_STATE _gl_mbsrtoc32s_state # define MBRTOWC mbrtoc32 -# define USES_C32 1 +# if GNULIB_MBRTOC32_REGULAR + /* If the 'mbrtoc32-regular' module is in use, we don't need to handle + a (size_t)(-3) return value from mbrtoc32. */ +# define USES_C32 0 +# else +# define USES_C32 1 +# endif # include "mbsrtowcs-impl.h" #else -- 2.39.5