Skip to content

Commit

Permalink
Use only one try block
Browse files Browse the repository at this point in the history
  • Loading branch information
shaopeng-gh committed Mar 14, 2024
1 parent 9b07e63 commit 6850ec2
Showing 1 changed file with 10 additions and 21 deletions.
31 changes: 10 additions & 21 deletions src/Sarif.Driver/OrderedFileSpecifier.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,35 +87,24 @@ private IEnumerable<IEnumeratedArtifact> EnumeratedArtifacts()

Task directoryEnumerationTask;

if (this.recurse)
directoryEnumerationTask = Task.Run(() =>
{
directoryEnumerationTask = Task.Run(() =>
try
{
try
if (this.recurse)
{
EnqueueAllFilesUnderDirectory(directory, filesToProcessChannel.Writer, filter, new SortedSet<string>(StringComparer.Ordinal));
}
finally
{
filesToProcessChannel.Writer.Complete();
}
});
}
else
{
directoryEnumerationTask = Task.Run(() =>
{
try
else
{
WriteFilesInDirectoryToChannel(directory, filesToProcessChannel, filter, new SortedSet<string>(StringComparer.Ordinal));
}
finally
{
filesToProcessChannel.Writer.Complete();
directoryEnumerationTask = Task.CompletedTask;
}
});
}
}
finally
{
filesToProcessChannel.Writer.Complete();
}
});

ChannelReader<string> reader = filesToProcessChannel.Reader;
while (!reader.Completion.IsCompleted)
Expand Down

0 comments on commit 6850ec2

Please sign in to comment.