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/gc.cc | 27 +++------------------------ 1 file changed, 3 insertions(+), 24 deletions(-) (limited to 'third_party/nix/src/libstore/gc.cc') diff --git a/third_party/nix/src/libstore/gc.cc b/third_party/nix/src/libstore/gc.cc index 262f17df0338..5c1ea3d58b69 100644 --- a/third_party/nix/src/libstore/gc.cc +++ b/third_party/nix/src/libstore/gc.cc @@ -7,6 +7,7 @@ #include #include +#include #include #include #include @@ -422,8 +423,8 @@ void LocalStore::findRuntimeRoots(Roots& roots, bool censor) { try { auto mapFile = fmt("/proc/%s/maps", ent->d_name); - auto mapLines = tokenizeString>( - readFile(mapFile, true), "\n"); + std::vector mapLines = + absl::StrSplit(readFile(mapFile, true), absl::ByChar('\n')); for (const auto& line : mapLines) { auto match = std::smatch{}; if (std::regex_match(line, match, mapRegex)) { @@ -452,31 +453,9 @@ void LocalStore::findRuntimeRoots(Roots& roots, bool censor) { } } -#if !defined(__linux__) - // lsof is really slow on OS X. This actually causes the gc-concurrent.sh test - // to fail. See: https://github.com/NixOS/nix/issues/3011 Because of this we - // disable lsof when running the tests. - if (getEnv("_NIX_TEST_NO_LSOF") == "") { - try { - std::regex lsofRegex(R"(^n(/.*)$)"); - auto lsofLines = tokenizeString>( - runProgram(LSOF, true, {"-n", "-w", "-F", "n"}), "\n"); - for (const auto& line : lsofLines) { - std::smatch match; - if (std::regex_match(line, match, lsofRegex)) - unchecked[match[1]].emplace("{lsof}"); - } - } catch (ExecError& e) { - /* lsof not installed, lsof failed */ - } - } -#endif - -#if defined(__linux__) readFileRoots("/proc/sys/kernel/modprobe", unchecked); readFileRoots("/proc/sys/kernel/fbsplash", unchecked); readFileRoots("/proc/sys/kernel/poweroff_cmd", unchecked); -#endif for (auto& [target, links] : unchecked) { if (isInStore(target)) { -- cgit 1.4.1