print_matches(): Don't check file name for each match.

We only process one file at a time.
This commit is contained in:
tastytea 2021-06-07 01:09:37 +02:00
parent 7b817c42d1
commit 8b5c0d289e
Signed by: tastytea
GPG Key ID: CFC39497F1B26E07
2 changed files with 15 additions and 19 deletions

View File

@ -37,27 +37,22 @@ using std::cout;
void print_matches(const std::vector<search::match> &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<std::string> metadata;
if (!opts.no_fn_epub)
{

View File

@ -25,6 +25,7 @@
namespace epubgrep::output
{
// Print the matches of an EPUB.
void print_matches(const std::vector<search::match> &matches,
const options::options &opts, bool single_file);