From 157250fc94590225a07926fdcca3d877529f5b84 Mon Sep 17 00:00:00 2001 From: "Gary R. Van Sickle" Date: Fri, 2 Feb 2024 16:56:24 -0600 Subject: [PATCH] Using string_views in MatchList::Print(). --- src/MatchList.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/MatchList.cpp b/src/MatchList.cpp index 4994f56..b14a693 100644 --- a/src/MatchList.cpp +++ b/src/MatchList.cpp @@ -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 };