GNU bug report logs - #26193
[0-9] versus [[:digit:]]

Previous Next

Package: grep;

Reported by: "John P. Linderman" <jpl.jpl <at> gmail.com>

Date: Mon, 20 Mar 2017 17:00:02 UTC

Severity: normal

Done: Jim Meyering <jim <at> meyering.net>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Paul Eggert <eggert <at> cs.ucla.edu>
To: "John P. Linderman" <jpl.jpl <at> gmail.com>, 26193 <at> debbugs.gnu.org
Cc: Gnulib bugs <bug-gnulib <at> gnu.org>
Subject: bug#26193: [0-9] versus [[:digit:]]
Date: Tue, 21 Mar 2017 19:09:41 -0700
[Message part 1 (text/plain, inline)]
John P. Linderman wrote:
> Using what is to me the more obvious [0-9] pattern takes almost 50 times as
> long as using the [[:digit:]] pattern. Seems very strange.

Thanks for reporting that. In general, patterns like [a-z] can be much slower 
than [[:lower:]] due to poorly-thought-out POSIX interfaces. However, [0-9] is a 
special case: we can optimize such patterns safely if both ends are ASCII 
digits. I installed the attached patch to Gnulib to do that; it fixes the 
performance glitch you noticed, at least for me.
[0001-dfa-make-0-9-faster-in-non-C-locales.patch (text/x-diff, attachment)]

This bug report was last modified 8 years and 66 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.