 Chromium Code Reviews
 Chromium Code Reviews Issue 211373003:
  Speed up directory listing in pub.  (Closed) 
  Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
    
  
    Issue 211373003:
  Speed up directory listing in pub.  (Closed) 
  Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart| Index: sdk/lib/_internal/pub/lib/src/io.dart | 
| diff --git a/sdk/lib/_internal/pub/lib/src/io.dart b/sdk/lib/_internal/pub/lib/src/io.dart | 
| index 1186cdeb86f012299ca5fc7ba3663b0df7c9bb52..7a0bdb4adc4ceb06eb2fc3996c11b5e2ef00ba66 100644 | 
| --- a/sdk/lib/_internal/pub/lib/src/io.dart | 
| +++ b/sdk/lib/_internal/pub/lib/src/io.dart | 
| @@ -245,41 +245,16 @@ String createSystemTempDir() { | 
| /// The returned paths are guaranteed to begin with [dir]. | 
| List<String> listDir(String dir, {bool recursive: false, | 
| bool includeHidden: false}) { | 
| - List<String> doList(String dir, Set<String> listedDirectories) { | 
| - var contents = <String>[]; | 
| + var entities = new Directory(dir).listSync(recursive: recursive); | 
| 
nweiz
2014/03/25 18:55:08
Add a comment that there is a known bug with this,
 
Bob Nystrom
2014/03/25 20:04:20
This is specified behavior now. The docs say: "If
 
nweiz
2014/03/25 20:14:12
That doesn't make it not a bug; if you want, call
 
Bob Nystrom
2014/03/26 00:51:38
Absent some platonic ideal of the correct behavior
 | 
| - // Avoid recursive symlinks. | 
| - var resolvedPath = canonicalize(dir); | 
| - if (listedDirectories.contains(resolvedPath)) return []; | 
| + isHidden(part) => part.startsWith(".") && part != "." && part != ".."; | 
| - listedDirectories = new Set<String>.from(listedDirectories); | 
| - listedDirectories.add(resolvedPath); | 
| - | 
| - log.io("Listing directory $dir."); | 
| - | 
| - var children = <String>[]; | 
| - for (var entity in new Directory(dir).listSync()) { | 
| - if (!includeHidden && path.basename(entity.path).startsWith('.')) { | 
| - continue; | 
| - } | 
| - | 
| - contents.add(entity.path); | 
| - if (entity is Directory) { | 
| - // TODO(nweiz): don't manually recurse once issue 4794 is fixed. | 
| - // Note that once we remove the manual recursion, we'll need to | 
| - // explicitly filter out files in hidden directories. | 
| - if (recursive) { | 
| - children.addAll(doList(entity.path, listedDirectories)); | 
| - } | 
| - } | 
| - } | 
| - | 
| - log.fine("Listed directory $dir:\n${contents.join('\n')}"); | 
| - contents.addAll(children); | 
| - return contents; | 
| + if (!includeHidden) { | 
| + entities = entities.where( | 
| + (entity) => !path.split(entity.path).any(isHidden)); | 
| } | 
| - return doList(dir, new Set<String>()); | 
| + return entities.map((entity) => entity.path).toList(); | 
| } | 
| /// Returns whether [dir] exists on the file system. This will return `true` for |