Short circuit IsXIDStart check.
Our common case is ASCII characters but, because those come at the start of the XID Start range they'll end up being checked _last_ as we binary search through the range. This means we're getting the worst case behaviour for our common character. This CL adds a quick check for [a-zA-Z] at the start of IsXIDStart to quickly determine if we're an ascii character. Change-Id: Iae733b0e8a64c855764cf58c0563a407e6a81f7d Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/97068 Kokoro: Kokoro <noreply+kokoro@google.com> Commit-Queue: Dan Sinclair <dsinclair@chromium.org> Reviewed-by: Ben Clayton <bclayton@google.com> Commit-Queue: Ben Clayton <bclayton@google.com>
This commit is contained in:
parent
afa7eff921
commit
3f9cc84d0a
|
@ -306,6 +306,11 @@ constexpr size_t kNumXIDContinueRanges = sizeof(kXIDContinueRanges) / sizeof(kXI
|
|||
} // namespace
|
||||
|
||||
bool CodePoint::IsXIDStart() const {
|
||||
// Short circuit ascii. It will end up being at the end of the binary search
|
||||
// but is our, currently, common case.
|
||||
if ((value >= 'a' && value <= 'z') || (value >= 'A' && value <= 'Z')) {
|
||||
return true;
|
||||
}
|
||||
return std::binary_search(kXIDStartRanges, kXIDStartRanges + kNumXIDStartRanges, *this);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue