about summary refs log tree commit diff
path: root/third_party/nix/src/libstore/store-api.cc
diff options
context:
space:
mode:
authorVincent Ambo <tazjin@google.com>2020-05-25T01·19+0100
committerVincent Ambo <tazjin@google.com>2020-05-25T01·19+0100
commitb99b368d17f2e806a61f7abb83c6d3a9e4bbdc38 (patch)
tree1f76047dd027421dcf79cdf4804fa5ff1bb08b2b /third_party/nix/src/libstore/store-api.cc
parent8cf1322a6fd5ae282d8a09fdba634f27a1a88560 (diff)
refactor(3p/nix/libutil): Replace hasPrefix/Suffix with Abseil r/845
Uses the equivalent absl::StartsWith and absl::EndsWith functions
instead.
Diffstat (limited to 'third_party/nix/src/libstore/store-api.cc')
-rw-r--r--third_party/nix/src/libstore/store-api.cc9
1 files changed, 5 insertions, 4 deletions
diff --git a/third_party/nix/src/libstore/store-api.cc b/third_party/nix/src/libstore/store-api.cc
index 54214e6f4e94..9440d78d5f12 100644
--- a/third_party/nix/src/libstore/store-api.cc
+++ b/third_party/nix/src/libstore/store-api.cc
@@ -3,6 +3,7 @@
 #include <future>
 #include <utility>
 
+#include <absl/strings/match.h>
 #include <absl/strings/numbers.h>
 #include <glog/logging.h>
 
@@ -771,7 +772,7 @@ bool ValidPathInfo::isContentAddressed(const Store& store) const {
                << "' claims to be content-addressed but isn't";
   };
 
-  if (hasPrefix(ca, "text:")) {
+  if (absl::StartsWith(ca, "text:")) {
     Hash hash(std::string(ca, 5));
     if (store.makeTextPath(storePathToName(path), hash, references) == path) {
       return true;
@@ -780,7 +781,7 @@ bool ValidPathInfo::isContentAddressed(const Store& store) const {
 
   }
 
-  else if (hasPrefix(ca, "fixed:")) {
+  else if (absl::StartsWith(ca, "fixed:")) {
     bool recursive = ca.compare(6, 2, "r:") == 0;
     Hash hash(std::string(ca, recursive ? 8 : 6));
     if (references.empty() &&
@@ -906,7 +907,7 @@ StoreType getStoreType(const std::string& uri, const std::string& stateDir) {
   if (uri == "daemon") {
     return tDaemon;
   }
-  if (uri == "local" || hasPrefix(uri, "/")) {
+  if (uri == "local" || absl::StartsWith(uri, "/")) {
     return tLocal;
   } else if (uri.empty() || uri == "auto") {
     if (access(stateDir.c_str(), R_OK | W_OK) == 0) {
@@ -930,7 +931,7 @@ static RegisterStoreImplementation regStore([](const std::string& uri,
       return std::shared_ptr<Store>(std::make_shared<UDSRemoteStore>(params));
     case tLocal: {
       Store::Params params2 = params;
-      if (hasPrefix(uri, "/")) {
+      if (absl::StartsWith(uri, "/")) {
         params2["root"] = uri;
       }
       return std::shared_ptr<Store>(std::make_shared<LocalStore>(params2));