Add a bad char heuristic to StringRef::find.
authorBenjamin Kramer <benny.kra@googlemail.com>
Sat, 15 Oct 2011 10:08:31 +0000 (10:08 +0000)
committerBenjamin Kramer <benny.kra@googlemail.com>
Sat, 15 Oct 2011 10:08:31 +0000 (10:08 +0000)
commit6e6a558ebce556476d8fd659b419a2760f2ab154
tree0331aaeaa342b5fd9f0adf98895d3d91e2182f4f
parente9b58d0aac4e89b53a4be0e6f289b66649e1512b
Add a bad char heuristic to StringRef::find.

Based on Horspool's simplified version of Boyer-Moore. We use a constant-sized table of
uint8_ts to keep cache thrashing low, needles bigger than 255 bytes are uncommon anyways.

The worst case is still O(n*m) but we do a lot better on the average case now.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@142061 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Support/StringRef.cpp
unittests/ADT/StringRefTest.cpp