Skip to content

Commit

Permalink
Using string_views in MatchList::Print().
Browse files Browse the repository at this point in the history
  • Loading branch information
Gary R. Van Sickle committed Feb 2, 2024
1 parent 21ef426 commit 157250f
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/MatchList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,19 +44,19 @@ void MatchList::clear() noexcept

void MatchList::Print(std::ostream &sstrm, OutputContext &output_context) const
{
std::string no_dotslash_fn;
const std::string empty_color_string {""};
std::string_view no_dotslash_fn;
static constexpr std::string empty_color_string {""};
bool color = output_context.is_color_enabled();

// If the file path starts with a "./", chop it off.
// This is to match the behavior of ack.
if(m_filename.find("./") == 0)
{
no_dotslash_fn = std::string(m_filename.begin()+2, m_filename.end());
no_dotslash_fn = std::string_view(m_filename.begin()+2, m_filename.end());
}
else
{
no_dotslash_fn = std::string(m_filename.begin(), m_filename.end());
no_dotslash_fn = std::string_view(m_filename.begin(), m_filename.end());
}

const std::string *color_filename { &empty_color_string };
Expand Down

0 comments on commit 157250f

Please sign in to comment.