[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] dfa: speed up [[:digit:]] and [[:xdigit:]]
From: |
Jim Meyering |
Subject: |
Re: [PATCH] dfa: speed up [[:digit:]] and [[:xdigit:]] |
Date: |
Thu, 06 May 2010 07:40:26 +0200 |
Paolo Bonzini wrote:
> There's no "multibyte pain" in these two classes, since POSIX
> and ISO C99 mandate their contents.
>
> Time for "./grep -x '[[:digit:]]' /usr/share/dict/linux.words"
> Before: 1.5s, after: 0.07s. (sed manages only 0.5s).
Nice!
> * src/dfa.c (predicates): Declare struct dfa_ctype separately
> from definition. Add sb_only.
> (find_pred): Return const struct dfa_ctype *.
> (parse_bracket_exp): Return const struct dfa_ctype *. Do
> not fill MBCSET for sb_only character types.
...
> +struct dfa_ctype {
...
> + predicate *func;
> + bool sb_only;
"sb" didn't click for me quickly enough. Perhaps it should have,
considering how "mb" == multi-byte, but I've seen "sb" used often enough
as an abbreviation of "struct stat buffer" that it'd be nice to name this
"single_byte_only" or maybe even just "single_byte".
...
> - if (MB_CUR_MAX > 1)
> + if (MB_CUR_MAX > 1 && !pred->sb_only)
ACK