Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using string_views in MatchList::Print(). #143

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading