about summary refs log tree commit diff
path: root/third_party/nix/src/libstore/local-store.cc
diff options
context:
space:
mode:
authorVincent Ambo <tazjin@google.com>2020-05-25T14·54+0100
committerVincent Ambo <tazjin@google.com>2020-05-25T14·54+0100
commitbf452cbc2ae2b209ec262ce858deca470d086f24 (patch)
tree198e98902be569301ecb9a821b0c9512b128f930 /third_party/nix/src/libstore/local-store.cc
parentb99b368d17f2e806a61f7abb83c6d3a9e4bbdc38 (diff)
refactor(3p/nix): Replace tokenizeStrings with absl::StrSplit r/846
This function was a custom (and inefficient in the case of
single-character delimiters) string splitter which was used all over
the codebase. Abseil provides an appropriate replacement function.
Diffstat (limited to 'third_party/nix/src/libstore/local-store.cc')
-rw-r--r--third_party/nix/src/libstore/local-store.cc10
1 files changed, 6 insertions, 4 deletions
diff --git a/third_party/nix/src/libstore/local-store.cc b/third_party/nix/src/libstore/local-store.cc
index faea0fbce5..ebc9129694 100644
--- a/third_party/nix/src/libstore/local-store.cc
+++ b/third_party/nix/src/libstore/local-store.cc
@@ -8,6 +8,7 @@
 #include <iostream>
 
 #include <absl/strings/numbers.h>
+#include <absl/strings/str_split.h>
 #include <fcntl.h>
 #include <glog/logging.h>
 #include <grp.h>
@@ -477,14 +478,15 @@ static void canonicalisePathMetaData_(const Path& path, uid_t fromUid,
       throw SysError("querying extended attributes of '%s'", path);
     }
 
-    for (auto& eaName : tokenizeString<Strings>(
-             std::string(eaBuf.data(), eaSize), std::string("\000", 1))) {
+    for (auto& eaName :
+         absl::StrSplit(std::string(eaBuf.data(), eaSize),
+                        absl::ByString(std::string("\000", 1)))) {
       /* Ignore SELinux security labels since these cannot be
          removed even by root. */
       if (eaName == "security.selinux") {
         continue;
       }
-      if (lremovexattr(path.c_str(), eaName.c_str()) == -1) {
+      if (lremovexattr(path.c_str(), std::string(eaName).c_str()) == -1) {
         throw SysError("removing extended attribute '%s' from '%s'", eaName,
                        path);
       }
@@ -702,7 +704,7 @@ void LocalStore::queryPathInfoUncached(
 
       s = (const char*)sqlite3_column_text(state->stmtQueryPathInfo, 6);
       if (s != nullptr) {
-        info->sigs = tokenizeString<StringSet>(s, " ");
+        info->sigs = absl::StrSplit(s, absl::ByChar(' '));
       }
 
       s = (const char*)sqlite3_column_text(state->stmtQueryPathInfo, 7);