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

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

Issue 429173002: Don't cache path Context based on cwd, as cwd involves a system-call to compute. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 5 months 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
Index: pkg/path/lib/src/context.dart
diff --git a/pkg/path/lib/src/context.dart b/pkg/path/lib/src/context.dart
index 823e0c28402d83b6b7db1e0f305174be5ac303f7..f28aad53589137b632101d15953a713d222df269 100644
--- a/pkg/path/lib/src/context.dart
+++ b/pkg/path/lib/src/context.dart
@@ -23,12 +23,8 @@ class Context {
/// On the browser, [style] defaults to [Style.url] and [current] defaults to
/// the current URL.
factory Context({Style style, String current}) {
- if (current == null) {
- if (style == null) {
- current = p.current;
- } else {
- current = ".";
- }
+ if (current == null && style != null) {
+ current = ".";
}
if (style == null) {
@@ -41,13 +37,17 @@ class Context {
return new Context._(style, current);
}
- Context._(this.style, this.current);
+ Context._(this.style, this._current);
/// The style of path that this context works with.
final InternalStyle style;
+ /// The current given when Context was created. If null, current should be
Bob Nystrom 2014/07/30 16:15:08 "current" -> "current directory". "should be" ->
Anders Johnsen 2014/07/31 06:19:42 Done.
+ /// evaluated from 'p.current'.
+ final String _current;
+
/// The current directory that relative paths will be relative to.
Bob Nystrom 2014/07/30 16:15:08 "will be" -> "are".
Anders Johnsen 2014/07/31 06:19:42 Done.
- final String current;
+ String get current => _current != null ? _current : p.current;
/// Gets the path separator for the context's [style]. On Mac and Linux,
/// this is `/`. On Windows, it's `\`.
« no previous file with comments | « pkg/path/lib/path.dart ('k') | pkg/path/pubspec.yaml » ('j') | pkg/path/pubspec.yaml » ('J')

Powered by Google App Engine
This is Rietveld 408576698