6976417416
previous commits. At the time we search the pattern for the "must" string, we now compute the longest offset from the beginning of the pattern at which the must string might be found. If that offset is found to be infinite (through use of "+" or "*"), we set it to -1 to disable the heuristics applied later. After we are done with pre-matching, we use that offset and the point in the text at which the must string was found to compute the earliest point at which the pattern might be found. Special care should be taken here. The variable "start" is passed to the automata-processing functions fast() and slow() to indicate the point in the text at which they should start working from. The real beginning of the text is passed in a struct match variable m, which is used to check for anchors. That variable, though, is initialized with "start", so we must not adjust "start" before "m" is properly initialized. Simple tests showed a speed increase from 100% to 400%, but they were biased in that regexec() was called for the whole file instead of line by line, and parenthized subexpressions were not searched for. This change adds a single integer to the size of the "guts" structure, and does not change the ABI. Further improvements possible: Since the speed increase observed here is so huge, one intuitive optimization would be to introduce a bias in the function that computes the "must" string so as to prefer a smaller string with a finite offset over a larger one with an infinite offset. Tests have shown this to be a bad idea, though, as the cost of false pre-matches far outweights the benefits of a must offset, even in biased situations. A number of other improvements suggest themselves, though: * identify the cases where the pattern is identical to the must string, and avoid entering fast() and slow() in these cases. * compute the maximum offset from the must string to the end of the pattern, and use that to set the point at which fast() and slow() should give up trying to find a match, and return then return to pre-matching. * return all the way to pre-matching if a "match" was found and later invalidated by back reference processing. Since back references are evil and should be avoided anyway, this is of little use. |
||
---|---|---|
.. | ||
compat | ||
csu | ||
libalias | ||
libatm | ||
libbind | ||
libc | ||
libc_r | ||
libcalendar | ||
libcam | ||
libcom_err | ||
libcompat | ||
libcrypt | ||
libdevstat | ||
libdisk | ||
libedit | ||
libfetch | ||
libform | ||
libftpio | ||
libgnumalloc | ||
libio | ||
libipsec | ||
libipx | ||
libkse | ||
libkvm | ||
libm | ||
libmd | ||
libmenu | ||
libncp | ||
libncurses | ||
libnetgraph | ||
libopie | ||
libpam | ||
libpanel | ||
libpcap | ||
libposix1e | ||
libpthread | ||
libradius | ||
libresolv | ||
librpcsvc | ||
libskey | ||
libss | ||
libstand | ||
libtacplus | ||
libtelnet | ||
libusb | ||
libusbhid | ||
libutil | ||
libvgl | ||
libwrap | ||
libxpg4 | ||
liby | ||
libz | ||
msun | ||
ncurses | ||
Makefile | ||
Makefile.inc |