Better string search algorithm for log -S
commit6d30b479f75f7133874a5658cb1fa34884a5448c
authorUoti Urpala <uau@symbol.nonexistent.invalid>
Wed, 30 Jul 2008 22:11:42 +0000 (31 01:11 +0300)
committerUoti Urpala <uau@glyph.nonexistent.invalid>
Sun, 10 Apr 2011 13:03:35 +0000 (10 16:03 +0300)
tree325ea91646e717c917af6daa4cbb93d1002ed1ff
parentc3f6163b0b6e2cfae1422050c9607db1130cded0
Better string search algorithm for log -S

The code did a string search by trying memcmp() at very possible
position. memcmp() with a size that is not known at compile time will be
optimized for larger matches and is a bad choice when you expect the
comparison to fail at the first byte. Use Boyer-Moore-Horspool string
search instead (long name for a simple algorithm).

I created the needle struct with the intention of keeping it for all
comparisons, but then didn't bother finding out where to store it (git
has quite an ugly mix of passing parameters in globals and passing
them as function arguments...) so it's always recreated in
diffcore_pickaxe.

Mainline git changed from memcmp to memmem after this commit was first
created. I haven't done exact timings on current speed differences.
diffcore-pickaxe.c