This is the mail archive of the libc-alpha@sources.redhat.com mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

More backref performance - no strncmp


> Note you cannot be ever sure regex won't have to compare 4K or
> longer strings, at which point at least on most arches my_memcmp
> will be way slower (lot of memcmp implementations compare 4 or
> 8 bytes at a time).

You're right, but I based my implementation on sed, which is probably the
most aggressive user of backreferences, because it is common to use them to
implement lookup tables such as this

:y
y/abcdefg/bcdefgh/
s/$/;01a2aa3aaa4aaaa etc/
s/\([0-9]\)\([0-9]*\);.*\1\(a*\).*/\3\2/
/[0-9]/by

For large strings, memcmp is indeed faster, but I think that using memcmp is
out of discussion because it incurs a 20% performance loss with respect to
strncmp due to startup overhead on small strings.

Anyway using strncmp is incorrect when there are nuls, and this ought to be
fixed.  Maybe unroll my_memcmp?

Paolo



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]