On 26/03/2026 17:41, Paul Eggert wrote:
On 3/26/26 07:37, Pádraig Brady wrote:

If I remove these lines from lib/mcel.h
and also have the above configure var set
I get faster cut -c:

-#ifdef __GLIBC__
-# undef mbrtoc32
-#endif

Let's remove those lines from lib/mcel.h if that helps performance in
the common GNU case. I put them in only because they helped performance
on GNU/Linux back in the day, but evidently that has changed.


We do replace mbrtowc() on glibc always currently,
but wc was changed to using mbrtoc32() in coreutils v9.4-37-g14d35d5ba
which thus took the slower path since then I think.

I'm a little lost here. Why do we always replace mbrtowc on glibc? And
why is mbrtoc32 not also replaced on glibc?

Well I'm not too sure on all this,
but the replacement seems due to mbrtowc and mbrtoc32 returning EILSEQ in the C 
locale
(as mentioned in the comment above the 3 lines referenced above in lib/mcel.h

With glibc-2.42,
With default configure options we get the following (and slower operation):

  $ grep -E '^(HAVE|REPLACE)_MBRTO' config.log
  HAVE_MBRTOC16='1'
  HAVE_MBRTOC32='1'
  HAVE_MBRTOWC='1'
  REPLACE_MBRTOC16='0'
  REPLACE_MBRTOC32='1'
  REPLACE_MBRTOWC='1'

With ./configure ac_cv_func_mbrtowc=no we get the following (and faster 
operation):

  HAVE_MBRTOC16='1'
  HAVE_MBRTOC32='1'
  HAVE_MBRTOWC='0'
  REPLACE_MBRTOC16='0'
  REPLACE_MBRTOC32='1'
  REPLACE_MBRTOWC='1'

cheers,
Padraig

Reply via email to