Commit 7bbd52bb authored by Jeremy Roman's avatar Jeremy Roman Committed by Commit Bot

Fast path for EqualsIgnoringASCIICase with a literal as the second argument.

This is a very common case, and this happens to produce smaller
(and in theory, slightly faster) code.

Change-Id: I33bbd12effe99d5890480d3d752fcd0df20f5486
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2106386
Commit-Queue: Kentaro Hara <haraken@chromium.org>
Auto-Submit: Jeremy Roman <jbroman@chromium.org>
Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Cr-Commit-Position: refs/heads/master@{#751579}
parent 44cd1d50
...@@ -253,6 +253,15 @@ WTF_EXPORT bool DeprecatedEqualIgnoringCaseAndNullity(const StringView&, ...@@ -253,6 +253,15 @@ WTF_EXPORT bool DeprecatedEqualIgnoringCaseAndNullity(const StringView&,
WTF_EXPORT bool EqualIgnoringASCIICase(const StringView&, const StringView&); WTF_EXPORT bool EqualIgnoringASCIICase(const StringView&, const StringView&);
template <size_t N>
inline bool EqualIgnoringASCIICase(const StringView& a,
const char (&literal)[N]) {
if (a.length() != N - 1 || (N == 1 && a.IsNull()))
return false;
return a.Is8Bit() ? EqualIgnoringASCIICase(a.Characters8(), literal, N - 1)
: EqualIgnoringASCIICase(a.Characters16(), literal, N - 1);
}
// TODO(esprehn): Can't make this an overload of WTF::equal since that makes // TODO(esprehn): Can't make this an overload of WTF::equal since that makes
// calls to equal() that pass literal strings ambiguous. Figure out if we can // calls to equal() that pass literal strings ambiguous. Figure out if we can
// replace all the callers with equalStringView and then rename it to equal(). // replace all the callers with equalStringView and then rename it to equal().
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment