[ADT] Rewrite the StringRef::find implementation to be simpler, clearer,
authorChandler Carruth <chandlerc@gmail.com>
Thu, 10 Sep 2015 11:17:49 +0000 (11:17 +0000)
committerChandler Carruth <chandlerc@gmail.com>
Thu, 10 Sep 2015 11:17:49 +0000 (11:17 +0000)
commit32e95cb90f61daf73034fe613df81f379266724e
tree97f92e3e9a0a017335bf1ccd2c41b6cd8496e92f
parent040f4f687d64cba1ea5d77675a24bcba8d212a12
[ADT] Rewrite the StringRef::find implementation to be simpler, clearer,
and tremendously less reliant on the optimizer to fix things.

The code is always necessarily looking for the entire length of the
string when doing the equality tests in this find implementation, but it
previously was needlessly re-checking the size each time among other
annoyances.

By writing this so simply an ddirectly in terms of memcmp, it also is
about 8x faster in a debug build, which in turn makes FileCheck about 2x
faster in 'ninja check-llvm'. This saves about 8% of the time for
FileCheck-heavy parts of the test suite like the x86 backend tests.

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