mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-07-01 19:03:41 +00:00
Fast path ASCII in unicode decode.
In the case of ASCII characters, which a lot of WGSL source is, the decoder can early out after a checking the value. Change-Id: Iff655565dde23b143fddb95c6c353a917e25e916 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/128120 Reviewed-by: Ben Clayton <bclayton@google.com> Commit-Queue: Ben Clayton <bclayton@google.com> Kokoro: Kokoro <noreply+kokoro@google.com>
This commit is contained in:
parent
89c89b7640
commit
9b726858ff
@ -336,6 +336,10 @@ std::pair<CodePoint, size_t> Decode(const uint8_t* ptr, size_t len) {
|
|||||||
if (len < 1) {
|
if (len < 1) {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
// Fast-path ASCII characters as they're always valid
|
||||||
|
if (ptr[0] <= 0x7f) {
|
||||||
|
return {CodePoint{ptr[0]}, 1};
|
||||||
|
}
|
||||||
|
|
||||||
// Lookup table for the first byte of a UTF-8 sequence.
|
// Lookup table for the first byte of a UTF-8 sequence.
|
||||||
// 0 indicates an invalid length.
|
// 0 indicates an invalid length.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user