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

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

Issue 309803003: Avoid using RegExps in path to work around issue 19090. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: code review Created 6 years, 7 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/src/internal_style.dart ('k') | pkg/path/lib/src/style/posix.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/path/lib/src/parsed_path.dart
diff --git a/pkg/path/lib/src/parsed_path.dart b/pkg/path/lib/src/parsed_path.dart
index 3f3c3b9cb645bec066b10b884cdff8e2cdf1b461..57773eee7b5884ba6394d50bafb6b2453ded8d06 100644
--- a/pkg/path/lib/src/parsed_path.dart
+++ b/pkg/path/lib/src/parsed_path.dart
@@ -52,19 +52,21 @@ class ParsedPath {
var parts = [];
var separators = [];
- var firstSeparator = style.separatorPattern.matchAsPrefix(path);
- if (firstSeparator != null) {
- separators.add(firstSeparator[0]);
- path = path.substring(firstSeparator[0].length);
+ var start = 0;
+
+ if (path.isNotEmpty && style.isSeparator(path.codeUnitAt(0))) {
+ separators.add(path[0]);
+ start = 1;
} else {
separators.add('');
}
- var start = 0;
- for (var match in style.separatorPattern.allMatches(path)) {
- parts.add(path.substring(start, match.start));
- separators.add(match[0]);
- start = match.end;
+ for (var i = start; i < path.length; i++) {
+ if (style.isSeparator(path.codeUnitAt(i))) {
+ parts.add(path.substring(start, i));
+ separators.add(path[i]);
+ start = i + 1;
+ }
}
// Add the final part, if any.
@@ -133,8 +135,7 @@ class ParsedPath {
var newSeparators = new List.generate(
newParts.length, (_) => style.separator, growable: true);
newSeparators.insert(0,
- isAbsolute && newParts.length > 0 &&
- root.contains(style.needsSeparatorPattern) ?
+ isAbsolute && newParts.length > 0 && style.needsSeparator(root) ?
style.separator : '');
parts = newParts;
« no previous file with comments | « pkg/path/lib/src/internal_style.dart ('k') | pkg/path/lib/src/style/posix.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698