[Support] Add fast path for StringRef::find with needle of length 2.
authorTatsuyuki Ishi <ishitatsuyuki@gmail.com>
Sun, 9 Oct 2022 00:58:07 +0000 (00:58 +0000)
committerDavid Blaikie <dblaikie@gmail.com>
Sun, 9 Oct 2022 00:58:07 +0000 (00:58 +0000)
commit5699692dfc7def5c0120258855e43b71e6d1b728
treea962e7f388e0b5346e4438482463c2b7aed3787c
parent7b85e765000df36fcc6a5191dec9a28f444245ba
[Support] Add fast path for StringRef::find with needle of length 2.

InclusionRewriter on Windows (CRLF line endings) will exercise this in a
hot path. Calling memcmp repeatedly would be highly suboptimal for that
use case, so give it a specialized path.

Reviewed By: efriedma

Differential Revision: https://reviews.llvm.org/D133660
llvm/lib/Support/StringRef.cpp