freebsd-dev/lib
Daniel C. Sobral e6a886d8db Enhance the optimization provided by pre-matching. Fix style bugs with
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.
2000-07-02 10:58:07 +00:00
..
compat
csu
libalias Fixed PunchFWHole(): 2000-06-27 14:56:07 +00:00
libatm
libbind
libc Enhance the optimization provided by pre-matching. Fix style bugs with 2000-07-02 10:58:07 +00:00
libc_r Fix typo in SEE ALSO section. 2000-06-28 03:15:21 +00:00
libcalendar
libcam
libcom_err
libcompat
libcrypt
libdevstat
libdisk _PATH_DEV'ify libdisk 2000-06-28 22:28:50 +00:00
libedit
libfetch Make restart work in active mode, too. 2000-06-29 10:44:10 +00:00
libform
libftpio
libgnumalloc
libio
libipsec
libipx
libkse If multiple threads are blocked in sigwait() for the same signal that does 2000-06-27 21:30:16 +00:00
libkvm
libm
libmd
libmenu
libncp
libncurses
libnetgraph - Make sure the message token returned by NgSendMsg() is non-negative 2000-06-21 23:01:07 +00:00
libopie
libpam
libpanel
libpcap
libposix1e
libpthread Fix typo in SEE ALSO section. 2000-06-28 03:15:21 +00:00
libradius
libresolv
librpcsvc
libskey
libss
libstand
libtacplus
libtelnet
libusb
libusbhid
libutil
libvgl
libwrap
libxpg4
liby
libz
msun
ncurses
Makefile
Makefile.inc