Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(94)

Unified Diff: pkg/analyzer/lib/src/util/fast_uri.dart

Issue 2660243002: Adapt to breaking change in SDK (TBR) (Closed)
Patch Set: Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/lib/src/util/fast_uri.dart
diff --git a/pkg/analyzer/lib/src/util/fast_uri.dart b/pkg/analyzer/lib/src/util/fast_uri.dart
index 691a51df306ffcdb02e1068e28cdcb2bc1e1b861..196dc01001d52f16a49752c916fd5d5399df76cb 100644
--- a/pkg/analyzer/lib/src/util/fast_uri.dart
+++ b/pkg/analyzer/lib/src/util/fast_uri.dart
@@ -134,6 +134,14 @@ class FastUri implements Uri {
}
@override
+ bool isScheme(String scheme) {
+ String thisScheme = this.scheme;
+ if (scheme == null) return thisScheme.isEmpty;
+ if (scheme.length != thisScheme.length) return false;
+ return _compareScheme(scheme, thisScheme);
+ }
+
+ @override
Uri normalizePath() {
return this;
}
@@ -230,6 +238,39 @@ class FastUri implements Uri {
}
/**
+ * Compares scheme characters in [scheme] and at the start of [uri].
+ *
+ * Returns `true` if [scheme] represents the same scheme as the start of
+ * [uri]. That means having the same characters, but possibly different case
+ * for letters.
+ *
+ * This function doesn't check that the characters are valid URI scheme
+ * characters. The [uri] is assumed to be valid, so if [scheme] matches
+ * it, it has to be valid too.
+ *
+ * The length should be tested before calling this function,
+ * so the scheme part of [uri] is known to have the same length as [scheme].
+ */
+ static bool _compareScheme(String scheme, String uri) {
+ for (int i = 0; i < scheme.length; i++) {
+ int schemeChar = scheme.codeUnitAt(i);
+ int uriChar = uri.codeUnitAt(i);
+ int delta = schemeChar ^ uriChar;
+ if (delta != 0) {
+ if (delta == 0x20) {
+ // Might be a case difference.
+ int lowerChar = uriChar | delta;
+ if (0x61 /*a*/ <= lowerChar && lowerChar <= 0x7a /*z*/) {
+ continue;
+ }
+ }
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
* This implementation was used before 'fast-URI' in Dart VM.
*/
static int _computeHashUsingCombine(FastUri uri) {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698