Skip to content

Commit

Permalink
More efficient getDirectoryContents
Browse files Browse the repository at this point in the history
  • Loading branch information
snoyberg committed Feb 17, 2015
1 parent 95f12a7 commit 90b8fc8
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions System/Directory.hs
Original file line number Diff line number Diff line change
Expand Up @@ -839,13 +839,16 @@ getDirectoryContents path =
bracket
(Posix.openDirStream path)
Posix.closeDirStream
loop
start
where
loop dirp = do
e <- Posix.readDirStream dirp
if null e then return [] else do
es <- loop dirp
return (e:es)
start dirp =
loop id
where
loop acc = do
e <- Posix.readDirStream dirp
if null e
then return (acc [])
else loop (acc . (e:))
#else
bracket
(Win32.findFirstFile (path </> "*"))
Expand Down

0 comments on commit 90b8fc8

Please sign in to comment.