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

Unified Diff: lib/src/context.dart

Issue 1473563003: Cache the current working directory. (Closed) Base URL: git@github.com:dart-lang/path@master
Patch Set: Code review changes Created 5 years, 1 month 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
« lib/path.dart ('K') | « lib/path.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/src/context.dart
diff --git a/lib/src/context.dart b/lib/src/context.dart
index 44bdde994ea46daec0052052e8aaea4bc176be2e..a05ffda602947b31077172bba0e324d30949dee0 100644
--- a/lib/src/context.dart
+++ b/lib/src/context.dart
@@ -411,6 +411,9 @@ class Context {
/// "/", no path can be determined. In this case, a [PathException] will be
/// thrown.
String relative(String path, {String from}) {
+ // Avoid expensive computation if the path is already relative.
+ if (from == null && this.isRelative(path)) return path;
+
// Avoid calling [current] since it is slow and calling join() when
// [from] is absolute does nothing.
if (from == null) {
« lib/path.dart ('K') | « lib/path.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698