Import Tint changes from Dawn
Changes:
- f9a43b982d1e59213b313e0e5705bbf74818f621 Remove unused string. by dan sinclair <dsinclair@chromium.org>
- 3f9cc84d0ac7ed0c188f45f3463ec152d91e21a2 Short circuit IsXIDStart check. by dan sinclair <dsinclair@chromium.org>
GitOrigin-RevId: f9a43b982d1e59213b313e0e5705bbf74818f621
Change-Id: I9057ab8f023c6faa9c2ec763d6196c9838265d92
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/96987
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
diff --git a/src/tint/reader/wgsl/lexer.cc b/src/tint/reader/wgsl/lexer.cc
index 22eedda..93392b6 100644
--- a/src/tint/reader/wgsl/lexer.cc
+++ b/src/tint/reader/wgsl/lexer.cc
@@ -357,9 +357,6 @@
return {};
}
- // Save the error string, for use by diagnostics.
- const auto str = std::string{substr(start, end - start)};
-
advance(end - start);
end_source(source);
diff --git a/src/tint/text/unicode.cc b/src/tint/text/unicode.cc
index bf28c4e..7339297 100644
--- a/src/tint/text/unicode.cc
+++ b/src/tint/text/unicode.cc
@@ -306,6 +306,11 @@
} // 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);
}