From bf452cbc2ae2b209ec262ce858deca470d086f24 Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Mon, 25 May 2020 15:54:14 +0100 Subject: refactor(3p/nix): Replace tokenizeStrings with absl::StrSplit 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. --- third_party/nix/src/libstore/local-store.cc | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'third_party/nix/src/libstore/local-store.cc') diff --git a/third_party/nix/src/libstore/local-store.cc b/third_party/nix/src/libstore/local-store.cc index faea0fbce56a..ebc912969423 100644 --- a/third_party/nix/src/libstore/local-store.cc +++ b/third_party/nix/src/libstore/local-store.cc @@ -8,6 +8,7 @@ #include #include +#include #include #include #include @@ -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( - 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(s, " "); + info->sigs = absl::StrSplit(s, absl::ByChar(' ')); } s = (const char*)sqlite3_column_text(state->stmtQueryPathInfo, 7); -- cgit 1.4.1