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 0df5ce05ae85257bbf96471396802c7723685194..8af548c82640e91fc126f9b29fcc099891cb9211 100644 |
--- a/pkg/analyzer/lib/src/util/fast_uri.dart |
+++ b/pkg/analyzer/lib/src/util/fast_uri.dart |
@@ -62,7 +62,23 @@ class FastUri implements Uri { |
bool get hasFragment => false; |
@override |
- int get hashCode => _text.hashCode; |
+ int get hashCode { |
+ // This code is copied from the standard Uri implementation. |
+ // It is important that Uri and FastUri generate compatible hashCodes |
+ // because Uri and FastUri may be used as keys in the same map. |
+ int combine(part, current) { |
+ // The sum is truncated to 30 bits to make sure it fits into a Smi. |
+ return (current * 31 + part.hashCode) & 0x3FFFFFFF; |
+ } |
+ return _hashCode ??= combine( |
+ scheme, |
+ combine( |
+ userInfo, |
+ combine( |
+ host, |
+ combine(port, |
+ combine(path, combine(query, combine(fragment, 1))))))); |
+ } |
@override |
bool get hasPort => false; |