More backref performance - no strncmp

Daniel Jacobowitz drow@mvista.com
Wed Oct 23 08:26:00 GMT 2002


On Wed, Oct 23, 2002 at 11:44:34AM +0200, Bonzini wrote:
> I think that using strncmp to match backreferences is incorrect because it
> fails when matching nuls, not to mention inefficient.  Also, the return
> value of memcmp and strncmp is quite `complicated' to compute while we only
> need a yes/no answer.  For this reason the attached patch replaces strncmp
> with a customized memcmp.  Performance improvement is on the order of 5%
> (2.1 s before, 1.98s after on factor.sed).
> 
> 2002-10-23  Paolo Bonzini  (bonzini@gnu.org)
> 
>         * posix/regexec.c (my_memcmp): new function.
>         Used instead of strncmp throughout the file.

I don't think this is a good idea... memcmp is a very highly optimized
function in the system library already; why not use it?

-- 
Daniel Jacobowitz
MontaVista Software                         Debian GNU/Linux Developer



More information about the Libc-alpha mailing list