Pārlūkot izejas kodu

cmSystemTool: Let EscapeQuotes accept a cm::string_view

Sebastian Holtermann 6 gadi atpakaļ
vecāks
revīzija
2c5454f227
2 mainītis faili ar 5 papildinājumiem un 5 dzēšanām
  1. 4 4
      Source/cmSystemTools.cxx
  2. 1 1
      Source/cmSystemTools.h

+ 4 - 4
Source/cmSystemTools.cxx

@@ -176,15 +176,15 @@ void cmSystemTools::ExpandRegistryValues(std::string& source,
 }
 }
 #endif
 #endif
 
 
-std::string cmSystemTools::EscapeQuotes(const std::string& str)
+std::string cmSystemTools::EscapeQuotes(cm::string_view str)
 {
 {
   std::string result;
   std::string result;
   result.reserve(str.size());
   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 += '\\';
     }
     }
-    result += *ch;
+    result += ch;
   }
   }
   return result;
   return result;
 }
 }

+ 1 - 1
Source/cmSystemTools.h

@@ -78,7 +78,7 @@ public:
                                    KeyWOW64 view = KeyWOW64_Default);
                                    KeyWOW64 view = KeyWOW64_Default);
 
 
   //! Escape quotes in a string.
   //! 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.  */
   /** Map help document name to file name.  */
   static std::string HelpFileName(std::string);
   static std::string HelpFileName(std::string);