Thanks, all. That puts the runtimes on equal footing: + wc conjectures 125441818 125441818 6249180939 conjectures + rusage /home/jpl/src/grep-3.0/src/grep P[[:digit:]] conjectures A[21]=11{11}:22 wrote: > On Tue, Mar 21, 2017 at 7:09 PM, Paul Eggert wrote: > > 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. > > Thank you, Paul. I confirmed that that solves it for me, too, with a > multibyte locale. I didn't reproduce it initially because I was using > LC_ALL=C. >