From 8b5c0d289e39f04d00eeb55342d38043889661a7 Mon Sep 17 00:00:00 2001 From: tastytea Date: Mon, 7 Jun 2021 01:09:37 +0200 Subject: [PATCH] print_matches(): Don't check file name for each match. We only process one file at a time. --- src/output.cpp | 33 ++++++++++++++------------------- src/output.hpp | 1 + 2 files changed, 15 insertions(+), 19 deletions(-) diff --git a/src/output.cpp b/src/output.cpp index de9c1fc..f36021a 100644 --- a/src/output.cpp +++ b/src/output.cpp @@ -37,27 +37,22 @@ using std::cout; void print_matches(const std::vector &matches, const options::options &opts, bool single_file) { - fs::path last_epub; + if (!single_file && !opts.no_fn_fs) + { + if (!opts.nocolor) + { + cout << termcolor::yellow; + } + cout << format(translate(" In {0:s}: \n").str(), + fs::relative(matches[0].filepath_epub)); + if (!opts.nocolor) + { + cout << termcolor::reset; + } + } + for (const auto &match : matches) { - if (!single_file && !opts.no_fn_fs) - { - if (match.filepath_epub != last_epub) - { - if (!opts.nocolor) - { - cout << termcolor::yellow; - } - cout << format(translate(" In {0:s}: \n").str(), - fs::relative(match.filepath_epub)); - last_epub = match.filepath_epub; - if (!opts.nocolor) - { - cout << termcolor::reset; - } - } - } - std::vector metadata; if (!opts.no_fn_epub) { diff --git a/src/output.hpp b/src/output.hpp index 376a1e4..5f25148 100644 --- a/src/output.hpp +++ b/src/output.hpp @@ -25,6 +25,7 @@ namespace epubgrep::output { +// Print the matches of an EPUB. void print_matches(const std::vector &matches, const options::options &opts, bool single_file);