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

Unified Diff: sdk/lib/_internal/pub/lib/src/package.dart

Issue 485893008: Cautionary tale about optimizing path manipulation. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Comments. 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
Index: sdk/lib/_internal/pub/lib/src/package.dart
diff --git a/sdk/lib/_internal/pub/lib/src/package.dart b/sdk/lib/_internal/pub/lib/src/package.dart
index 29c9b1fadc4686bbad71826ac0134bbe11045728..211eb37e6a1de862d7c030b152014e9af64bcc37 100644
--- a/sdk/lib/_internal/pub/lib/src/package.dart
+++ b/sdk/lib/_internal/pub/lib/src/package.dart
@@ -172,6 +172,17 @@ class Package {
}
return files.where((file) {
+ // Using substring here is generally problematic in cases where dir has
+ // one or more trailing slashes. If you do listDir("foo"), you'll get back
+ // paths like "foo/bar". If you do listDir("foo/"), you'll get "foo/bar"
+ // (note the trailing slash was dropped. If you do listDir("foo//"),
+ // you'll get "foo//bar".
+ //
+ // This means if you strip off the prefix, the resulting string may have a
+ // leading separator (if the prefix did not have a trailing one) or it may
+ // not. However, since we are only using the results of that to call
+ // contains() on, the leading separator is harmless.
+ assert(file.startsWith(beneath));
file = file.substring(beneath.length);
return !_blacklistedFiles.any(file.endsWith) &&
!_blacklistedDirs.any(file.contains);
« no previous file with comments | « sdk/lib/_internal/pub/lib/src/io.dart ('k') | sdk/lib/_internal/pub/test/build/ignores_existing_compiled_js_files_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698