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

Unified Diff: pkg/path/lib/path.dart

Issue 58903005: Have pkg/path track the current working directory if it changes. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 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
« no previous file with comments | « no previous file | pkg/path/test/io_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/path/lib/path.dart
diff --git a/pkg/path/lib/path.dart b/pkg/path/lib/path.dart
index e91310ac5d0c7c662326fbb6fe968b00d1759aa2..7b955e6e0e244b2791bcb02652b39e322a52444c 100644
--- a/pkg/path/lib/path.dart
+++ b/pkg/path/lib/path.dart
@@ -46,10 +46,6 @@
/// even when the program is run on a POSIX machine.
library path;
-/// An internal builder for the current OS so we can provide a straight
-/// functional interface and not require users to create one.
-final _builder = new Builder();
-
/// A default builder for manipulating POSIX paths.
final posix = new Builder(style: Style.posix);
@@ -64,6 +60,22 @@ final url = new Builder(style: Style.url);
void _growListFront(List list, int length, fillValue) =>
list.insertAll(0, new List.filled(length, fillValue));
+/// The result of [Uri.base] last time the current working directory was
+/// calculated.
+///
+/// This is used to invalidate [_cachedBuilder] when the working directory has
+/// changed since the last time a function was called.
+Uri _lastBaseUri;
+
+/// An internal builder for the current OS so we can provide a straight
+/// functional interface and not require users to create one.
+Builder get _builder {
+ if (_cachedBuilder != null && Uri.base == _lastBaseUri) return _cachedBuilder;
+ _lastBaseUri = Uri.base;
+ _cachedBuilder = new Builder();
+ return _cachedBuilder;
+}
+Builder _cachedBuilder;
/// Gets the path to the current working directory.
///
« no previous file with comments | « no previous file | pkg/path/test/io_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698