Cache canonicalized version of paths in path dependencies (#4495)
diff --git a/lib/src/source/path.dart b/lib/src/source/path.dart
index 921e95e..a33eba9 100644
--- a/lib/src/source/path.dart
+++ b/lib/src/source/path.dart
@@ -270,6 +270,9 @@
final String path;
final bool relative;
+ // Canonicalization is rather slow - cache the result;
+ late final String _canonicalizedPath = canonicalize(path);
+
PathDescription(this.path, this.relative) : assert(!p.isRelative(path));
@override
String format() {
@@ -294,11 +297,11 @@
@override
bool operator ==(Object other) {
return other is PathDescription &&
- canonicalize(path) == canonicalize(other.path);
+ _canonicalizedPath == other._canonicalizedPath;
}
@override
- int get hashCode => canonicalize(path).hashCode;
+ int get hashCode => _canonicalizedPath.hashCode;
}
class ResolvedPathDescription extends ResolvedDescription {