grep: Simplify session_finalize

This commit is contained in:
Leonard Hecker
2026-06-05 17:04:29 +02:00
parent bc61aece73
commit 265a562c26
+13 -12
View File
@@ -643,18 +643,19 @@ impl<'a> Searcher<'a> {
/// End-of-file bookkeeping: count / `-L` / binary notice.
fn session_finalize(&mut self, path: &Path) -> io::Result<bool> {
if self.config.quiet {
return Ok(self.session_any_match());
}
if self.config.count && !self.config.files_with_matches && !self.config.files_without_match
{
self.writer.write_count(self.session_match_count, path)?;
}
if self.config.files_without_match && !self.session_any_match() {
self.writer.write_filename(path)?;
}
if self.session_should_emit_binary_notice() {
self.writer.report_binary_match(path);
if !self.config.quiet {
if self.config.count
&& !self.config.files_with_matches
&& !self.config.files_without_match
{
self.writer.write_count(self.session_match_count, path)?;
}
if self.config.files_without_match && !self.session_any_match() {
self.writer.write_filename(path)?;
}
if self.session_should_emit_binary_notice() {
self.writer.report_binary_match(path);
}
}
Ok(self.session_any_match())
}