Skip to content

Commit

Permalink
Trivial: Inline unused listDirectory into iterateDirectory
Browse files Browse the repository at this point in the history
In practice we only every iterate directories in a foreach,
which means iterateDirectory is the only function ever used.
  • Loading branch information
Geod24 committed Dec 19, 2023
1 parent eb305cf commit 2afeafd
Showing 1 changed file with 6 additions and 14 deletions.
20 changes: 6 additions & 14 deletions source/dub/internal/vibecompat/core/file.d
Original file line number Diff line number Diff line change
Expand Up @@ -253,23 +253,15 @@ void ensureDirectory(NativePath path)
/**
Enumerates all files in the specified directory.
*/
void listDirectory(NativePath path, scope bool delegate(FileInfo info) del)
{
foreach( DirEntry ent; dirEntries(path.toNativeString(), SpanMode.shallow) )
if( !del(makeFileInfo(ent)) )
break;
}

/// ditto
int delegate(scope int delegate(ref FileInfo)) iterateDirectory(NativePath path)
{
int iterator(scope int delegate(ref FileInfo) del){
int ret = 0;
listDirectory(path, (fi){
ret = del(fi);
return ret == 0;
});
return ret;
foreach (DirEntry ent; dirEntries(path.toNativeString(), SpanMode.shallow)) {
auto fi = makeFileInfo(ent);
if (auto res = del(fi))
return res;
}
return 0;
}
return &iterator;
}
Expand Down

0 comments on commit 2afeafd

Please sign in to comment.