about summary refs log tree commit diff
path: root/third_party/nix/src/libstore/nar-info-disk-cache.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/nar-info-disk-cache.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/nar-info-disk-cache.cc')
-rw-r--r--third_party/nix/src/libstore/nar-info-disk-cache.cc11
1 files changed, 7 insertions, 4 deletions
diff --git a/third_party/nix/src/libstore/nar-info-disk-cache.cc b/third_party/nix/src/libstore/nar-info-disk-cache.cc
index 19ef2c9d74..0a7a0dc22c 100644
--- a/third_party/nix/src/libstore/nar-info-disk-cache.cc
+++ b/third_party/nix/src/libstore/nar-info-disk-cache.cc
@@ -1,5 +1,7 @@
 #include "nar-info-disk-cache.hh"
 
+#include <absl/strings/str_cat.h>
+#include <absl/strings/str_split.h>
 #include <glog/logging.h>
 #include <sqlite3.h>
 
@@ -227,14 +229,15 @@ class NarInfoDiskCacheImpl : public NarInfoDiskCache {
           narInfo->fileSize = queryNAR.getInt(5);
           narInfo->narHash = Hash(queryNAR.getStr(6));
           narInfo->narSize = queryNAR.getInt(7);
-          for (auto& r : tokenizeString<Strings>(queryNAR.getStr(8), " ")) {
-            narInfo->references.insert(cache.storeDir + "/" + r);
+          for (auto r : absl::StrSplit(queryNAR.getStr(8), absl::ByChar(' '))) {
+            narInfo->references.insert(absl::StrCat(cache.storeDir, "/", r));
           }
           if (!queryNAR.isNull(9)) {
             narInfo->deriver = cache.storeDir + "/" + queryNAR.getStr(9);
           }
-          for (auto& sig : tokenizeString<Strings>(queryNAR.getStr(10), " ")) {
-            narInfo->sigs.insert(sig);
+          for (auto& sig :
+               absl::StrSplit(queryNAR.getStr(10), absl::ByChar(' '))) {
+            narInfo->sigs.insert(std::string(sig));
           }
           narInfo->ca = queryNAR.getStr(11);