From 2c5454f227027552966519c40feb2732b37ec542 Mon Sep 17 00:00:00 2001 From: Sebastian Holtermann Date: Sun, 28 Jul 2019 16:01:58 +0200 Subject: cmSystemTool: Let EscapeQuotes accept a cm::string_view --- Source/cmSystemTools.cxx | 8 ++++---- Source/cmSystemTools.h | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index 1e9580c..3715cc6 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -176,15 +176,15 @@ void cmSystemTools::ExpandRegistryValues(std::string& source, } #endif -std::string cmSystemTools::EscapeQuotes(const std::string& str) +std::string cmSystemTools::EscapeQuotes(cm::string_view str) { std::string result; result.reserve(str.size()); - for (const char* ch = str.c_str(); *ch != '\0'; ++ch) { - if (*ch == '"') { + for (const char ch : str) { + if (ch == '"') { result += '\\'; } - result += *ch; + result += ch; } return result; } diff --git a/Source/cmSystemTools.h b/Source/cmSystemTools.h index 87f0a11..8b60dcd 100644 --- a/Source/cmSystemTools.h +++ b/Source/cmSystemTools.h @@ -78,7 +78,7 @@ public: KeyWOW64 view = KeyWOW64_Default); //! Escape quotes in a string. - static std::string EscapeQuotes(const std::string& str); + static std::string EscapeQuotes(cm::string_view str); /** Map help document name to file name. */ static std::string HelpFileName(std::string); -- cgit v0.12