[regex] Speed up single-byte .

Paolo Bonzini paolo.bonzini@lu.unisi.ch
Wed Dec 1 13:18:00 GMT 2004


C locale searches spend a lot of time (up to 10-15% for bug-regex11) 
calling functions for multibyte matches, because ACCEPT_MB_NODE passes 
OP_PERIOD nodes even if dfa->mb_cur_max == 1.

The attached patch does not use ACCEPT_MB_NODE to discriminate such 
nodes, and instead relies on a bitfield within the token type.

This does not apply to UTF-8 searches yet, but I have another patch to 
speed up UTF-8 searches, lowering OP_PERIOD to character ranges instead 
of using OP_UTF8_PERIOD.  After that one, many UTF-8 searches won't go 
through the slow multi-byte path anymore.

I wanted to ask if it is ok to use [\x00-\x7F]|[\xC2-\xFF][\x80-\xBF]* 
instead of the full UTF-8 format.  This sequence is more efficient 
memory-wise, but it accepts invalid UTF-8 sequences, for example 
\xE0\xA0\x80.

Paolo
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: regex-speedup-accept-mb.patch
URL: <http://sourceware.org/pipermail/libc-alpha/attachments/20041201/dc400326/attachment.ksh>


More information about the Libc-alpha mailing list