strstr()

Petr Baudis pasky@suse.cz
Fri Jul 14 12:04:00 GMT 2006


Dear diary, on Sun, Jul 09, 2006 at 02:38:56AM CEST, I got a letter
where Tor Myklebust <tmyklebu@caffeine.csclub.uwaterloo.ca> said that...
> I've attached a strstr() implementation that uses the present code on 
> short patterns but switches over to a linear-time, constant-space 
> algorithm on longer patterns.  It was made against the glibc-2.3.2 package 
> from Debian sarge.  I've tested this patch extensively on both an i386 
> machine and an AMD64 machine, and have found no problems.  (It is, of 
> course, possible that I have overlooked all of its bugs.)

  did you do any benchmarks? It would be good to first see how does it
actually affect performance for various haystack-needle length
configurations. It seems that the performance impact on short haystack +
short needle would be non-negligible and it's more sensible to optimize
for that case; applications requiring large searches are more likely to
have own fast string search implementations.

-- 
				Petr "Pasky" Baudis
Stuff: http://pasky.or.cz/
Snow falling on Perl. White noise covering line noise.
Hides all the bugs too. -- J. Putnam



More information about the Libc-alpha mailing list