Przeglądaj źródła

cmSystemTools: Simplify string case conversion methods

Take advantage of KWSys SystemTools' new move semantics.
Brad King 2 tygodni temu
rodzic
commit
51e3b1b4b2
2 zmienionych plików z 10 dodań i 32 usunięć
  1. 0 24
      Source/cmSystemTools.cxx
  2. 10 8
      Source/cmSystemTools.h

+ 0 - 24
Source/cmSystemTools.cxx

@@ -457,30 +457,6 @@ void cmSystemTools::ExpandRegistryValues(std::string& source,
 }
 #endif
 
-// Return a lower case string
-std::string cmSystemTools::LowerCase(cm::string_view s)
-{
-  std::string n;
-  n.resize(s.size());
-  for (size_t i = 0; i < s.size(); i++) {
-    n[i] = static_cast<std::string::value_type>(
-      tolower(static_cast<unsigned char>(s[i])));
-  }
-  return n;
-}
-
-// Return an upper case string
-std::string cmSystemTools::UpperCase(cm::string_view s)
-{
-  std::string n;
-  n.resize(s.size());
-  for (size_t i = 0; i < s.size(); i++) {
-    n[i] = static_cast<std::string::value_type>(
-      toupper(static_cast<unsigned char>(s[i])));
-  }
-  return n;
-}
-
 std::string cmSystemTools::HelpFileName(cm::string_view str)
 {
   std::string name(str);

+ 10 - 8
Source/cmSystemTools.h

@@ -40,20 +40,22 @@ public:
   using Superclass = cmsys::SystemTools;
   using Encoding = cmProcessOutput::Encoding;
 
-  /**
-   * Return a lower case string
-   */
-  static std::string LowerCase(cm::string_view);
+  /** Return a lower-case string.  */
+  static std::string LowerCase(cm::string_view s)
+  {
+    return cmsys::SystemTools::LowerCase(std::string(s));
+  }
   static std::string LowerCase(char const* s)
   {
     return LowerCase(cm::string_view{ s });
   }
   using cmsys::SystemTools::LowerCase;
 
-  /**
-   * Return an upper case string
-   */
-  static std::string UpperCase(cm::string_view);
+  /** Return an upper-case string.  */
+  static std::string UpperCase(cm::string_view s)
+  {
+    return cmsys::SystemTools::UpperCase(std::string(s));
+  }
   static std::string UpperCase(char const* s)
   {
     return UpperCase(cm::string_view{ s });