Subject: bug#16966: [PATCH] grep: optimization with the superset of DFA

From: Paolo Bonzini <[email-masked]>
Date: Tue, 01 Apr 2014 10:16:32 +0200

Il 28/03/2014 18:20, Norihiro Tanaka ha scritto:
> I rebased this patch, and added four fixes to it.
>
>  1. Fix for the conditions that the superset is used.  No longer use it
>     when don't include any normal chars and CSETs. (dfasuperset)
>
>  2. Ignore any letter constrations.  Otherwise, it mayn't be able to be
>     a superset of the original dfa. (dfasuperset)
>
>  3. Change return type of dfahint().  It can check whether used or not
>     from caller.(dfahint)
>
>  4. If both kwset and dfahint() aren't used, run DFA matcher in whole
>     range still.

For ANYCHAR, you can convert it to CSET{1,mb_cur_max} or, even better, 
(single-CSET | lead-CSET full-CSET{0,mb_cur_max-1}).

Single-CSET and lead-CSET can be computed by looping over the 256 
characters with mbrtowc and looking respectively for non-negative or -2 
return values.

Paolo