From 77616f46817b6527c7e515de547625e554df21f9 Mon Sep 17 00:00:00 2001 From: Rolf Eike Beer Date: Fri, 20 Mar 2020 20:51:06 +0100 Subject: pass cm::string_view to cmVisualStudioSlnParser::ParseTag() --- Source/cmVisualStudioSlnParser.cxx | 10 +++++----- Source/cmVisualStudioSlnParser.h | 5 +++-- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/Source/cmVisualStudioSlnParser.cxx b/Source/cmVisualStudioSlnParser.cxx index 4533e9b..d7822b1 100644 --- a/Source/cmVisualStudioSlnParser.cxx +++ b/Source/cmVisualStudioSlnParser.cxx @@ -517,7 +517,7 @@ bool cmVisualStudioSlnParser::ParseMultiValueTag(const std::string& line, State& state) { size_t idxEqualSign = line.find('='); - const std::string& fullTag = line.substr(0, idxEqualSign); + auto fullTag = cm::string_view(line).substr(0, idxEqualSign); if (!this->ParseTag(fullTag, parsedLine, state)) return false; if (idxEqualSign != line.npos) { @@ -560,7 +560,7 @@ bool cmVisualStudioSlnParser::ParseSingleValueTag(const std::string& line, State& state) { size_t idxEqualSign = line.find('='); - const std::string& fullTag = line.substr(0, idxEqualSign); + auto fullTag = cm::string_view(line).substr(0, idxEqualSign); if (!this->ParseTag(fullTag, parsedLine, state)) return false; if (idxEqualSign != line.npos) { @@ -586,17 +586,17 @@ bool cmVisualStudioSlnParser::ParseKeyValuePair(const std::string& line, return true; } -bool cmVisualStudioSlnParser::ParseTag(const std::string& fullTag, +bool cmVisualStudioSlnParser::ParseTag(cm::string_view fullTag, ParsedLine& parsedLine, State& state) { size_t idxLeftParen = fullTag.find('('); - if (idxLeftParen == fullTag.npos) { + if (idxLeftParen == cm::string_view::npos) { parsedLine.SetTag(cmTrimWhitespace(fullTag)); return true; } parsedLine.SetTag(cmTrimWhitespace(fullTag.substr(0, idxLeftParen))); size_t idxRightParen = fullTag.rfind(')'); - if (idxRightParen == fullTag.npos) { + if (idxRightParen == cm::string_view::npos) { this->LastResult.SetError(ResultErrorInputStructure, state.GetCurrentLine()); return false; diff --git a/Source/cmVisualStudioSlnParser.h b/Source/cmVisualStudioSlnParser.h index 6c05633..4557cdb 100644 --- a/Source/cmVisualStudioSlnParser.h +++ b/Source/cmVisualStudioSlnParser.h @@ -9,6 +9,8 @@ #include #include +#include + #include class cmSlnData; @@ -97,8 +99,7 @@ protected: bool ParseKeyValuePair(const std::string& line, ParsedLine& parsedLine, State& state); - bool ParseTag(const std::string& fullTag, ParsedLine& parsedLine, - State& state); + bool ParseTag(cm::string_view fullTag, ParsedLine& parsedLine, State& state); bool ParseValue(const std::string& value, ParsedLine& parsedLine); }; -- cgit v0.12