From 09977c181641dd4feea8fc13bf718f0f9cfe05bb Mon Sep 17 00:00:00 2001 From: Sebastian Holtermann Date: Sun, 28 Jul 2019 16:07:39 +0200 Subject: cmSystemTool: Let TrimWhitespace accept a cm::string_view --- Source/cmSystemTools.cxx | 12 ++++++------ Source/cmSystemTools.h | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index de68bf4..e0005a0 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -197,16 +197,16 @@ std::string cmSystemTools::HelpFileName(cm::string_view str) return name; } -std::string cmSystemTools::TrimWhitespace(const std::string& s) +std::string cmSystemTools::TrimWhitespace(cm::string_view str) { - std::string::const_iterator start = s.begin(); - while (start != s.end() && cm_isspace(*start)) { + auto start = str.begin(); + while (start != str.end() && cm_isspace(*start)) { ++start; } - if (start == s.end()) { - return ""; + if (start == str.end()) { + return std::string(); } - std::string::const_iterator stop = s.end() - 1; + auto stop = str.end() - 1; while (cm_isspace(*stop)) { --stop; } diff --git a/Source/cmSystemTools.h b/Source/cmSystemTools.h index 46eab57..ac1aa80 100644 --- a/Source/cmSystemTools.h +++ b/Source/cmSystemTools.h @@ -86,7 +86,7 @@ public: /** * Returns a string that has whitespace removed from the start and the end. */ - static std::string TrimWhitespace(const std::string& s); + static std::string TrimWhitespace(cm::string_view str); using MessageCallback = std::function; /** -- cgit v0.12