Skip to content

Commit

Permalink
Cache canonicalized version of paths in path dependencies (#4495)
Browse files Browse the repository at this point in the history
  • Loading branch information
sigurdm authored Jan 16, 2025
1 parent eaf03b3 commit 710265b
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/src/source/path.dart
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,9 @@ class PathDescription extends Description {
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() {
Expand All @@ -294,11 +297,11 @@ class PathDescription extends Description {
@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 {
Expand Down

0 comments on commit 710265b

Please sign in to comment.