]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
Convert nonstd::string_view to std::string using constructor
authorJoel Rosdahl <joel@rosdahl.net>
Tue, 20 Jul 2021 05:14:46 +0000 (07:14 +0200)
committerJoel Rosdahl <joel@rosdahl.net>
Tue, 20 Jul 2021 17:43:01 +0000 (19:43 +0200)
to_string doesn’t exist in the std::string_view form, so use the
std::string constructor to make a future conversion to newer C++
versions easier.

src/storage/Storage.cpp
src/storage/secondary/HttpStorage.cpp
src/storage/secondary/RedisStorage.cpp
src/util/path.cpp

index 74fc0db2e7ec8726cfc94acb49ada7dd04d22dd5..81d30586b8a84270ac516fab579c4205e0387d1e 100644 (file)
@@ -102,7 +102,7 @@ parse_storage_config(const nonstd::string_view entry)
   }
 
   SecondaryStorageConfig result;
-  result.params.url = to_string(parts[0]);
+  result.params.url = std::string(parts[0]);
   // The Url class is parsing the URL object lazily; check if successful.
   try {
     std::ignore = result.params.url.host();
@@ -128,7 +128,7 @@ parse_storage_config(const nonstd::string_view entry)
     }
     result.params.attributes.emplace_back(
       secondary::SecondaryStorage::Backend::Attribute{
-        to_string(key), value, to_string(raw_value)});
+        std::string(key), value, std::string(raw_value)});
   }
 
   return result;
index 1ee4078177ba1ba2f0d6b06cef9f219eb1c229f7..7d54687f8e92abec5ccc8c38222c1b303ce2c9a2 100644 (file)
@@ -154,8 +154,8 @@ HttpStorageBackend::HttpStorageBackend(const Params& params)
       throw core::Fatal("Expected username:password in URL but got \"{}\"",
                         params.url.user_info());
     }
-    m_http_client.set_basic_auth(to_string(pair.first).c_str(),
-                                 to_string(*pair.second).c_str());
+    m_http_client.set_basic_auth(std::string(pair.first).c_str(),
+                                 std::string(*pair.second).c_str());
   }
 
   m_http_client.set_default_headers({
index 518e97cacb851bbc204e9e2c37209a4251c1e6de..09943c8e7e82ec3aed5401b51546e81712303990 100644 (file)
@@ -84,10 +84,10 @@ split_user_info(const std::string& user_info)
     return {nonstd::nullopt, nonstd::nullopt};
   } else if (pair.second) {
     // redis://USERNAME:PASSWORD@HOST
-    return {to_string(*pair.second), to_string(pair.first)};
+    return {std::string(*pair.second), std::string(pair.first)};
   } else {
     // redis://PASSWORD@HOST
-    return {to_string(pair.first), nonstd::nullopt};
+    return {std::string(pair.first), nonstd::nullopt};
   }
 }
 
index e689bd20f52d22643294a2598c928fe785c4df7b..0648c2057e859b35c736b740ecc4e460b95c55cb 100644 (file)
@@ -51,7 +51,7 @@ std::string
 to_absolute_path(nonstd::string_view path)
 {
   if (util::is_absolute_path(path)) {
-    return to_string(path);
+    return std::string(path);
   } else {
     return Util::normalize_absolute_path(
       FMT("{}/{}", Util::get_actual_cwd(), path));