diff options
author | Andreas Rumpf <rumpf_a@web.de> | 2015-02-25 22:58:03 +0100 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2015-02-25 22:58:03 +0100 |
commit | 0ff4ed0ff30764dd4792396cd7a9eedfd8d0eee9 (patch) | |
tree | 075f6baa13e6250d21e164ba5d25c98740992cbb /lib/pure/os.nim | |
parent | fce2ff161ea55bb73c076ab20d90730399a4059e (diff) | |
parent | 5e8eaa5f9755a6c8ed73ae0e49d399ac2dd3217c (diff) | |
download | Nim-0ff4ed0ff30764dd4792396cd7a9eedfd8d0eee9.tar.gz |
Merge pull request #2208 from def-/walkdir
Speed up walkDir significantly
Diffstat (limited to 'lib/pure/os.nim')
-rw-r--r-- | lib/pure/os.nim | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/pure/os.nim b/lib/pure/os.nim index ceeba182f..bf581667b 100644 --- a/lib/pure/os.nim +++ b/lib/pure/os.nim @@ -1299,8 +1299,16 @@ iterator walkDir*(dir: string): tuple[kind: PathComponent, path: string] {. if y != "." and y != "..": var s: TStat y = dir / y - if lstat(y, s) < 0'i32: break var k = pcFile + + when defined(linux) or defined(macosx) or defined(bsd): + if x.d_type != DT_UNKNOWN: + if x.d_type == DT_DIR: k = pcDir + if x.d_type == DT_LNK: k = succ(k) + yield (k, y) + continue + + if lstat(y, s) < 0'i32: break if S_ISDIR(s.st_mode): k = pcDir if S_ISLNK(s.st_mode): k = succ(k) yield (k, y) |