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

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, 4 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
« no previous file with comments | « pkg/path/lib/path.dart ('k') | pkg/path/pubspec.yaml » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..89010491e51e4951bd32076b8ad80a4b4ea506b3 100644
--- a/pkg/path/lib/src/context.dart
+++ b/pkg/path/lib/src/context.dart
@@ -10,6 +10,8 @@ import 'parsed_path.dart';
import 'path_exception.dart';
import '../path.dart' as p;
+Context createInternal() => new Context._internal();
+
/// An instantiable class for manipulating paths. Unlike the top-level
/// functions, this lets you explicitly select what platform the paths will use.
class Context {
@@ -41,13 +43,20 @@ class Context {
return new Context._(style, current);
}
- Context._(this.style, this.current);
+ /// Create a [Context] to be used internally within path.
+ Context._internal() : style = Style.platform;
+
+ Context._(this.style, this._current);
/// The style of path that this context works with.
final InternalStyle style;
- /// The current directory that relative paths will be relative to.
- final String current;
+ /// The current directory given when Context was created. If null, current
+ /// directory is evaluated from 'p.current'.
+ final String _current;
+
+ /// The current directory that relative paths are relative to.
+ 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') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698