diff --git a/src/libexpr/include/nix/expr/eval.hh b/src/libexpr/include/nix/expr/eval.hh index 75ed12664..f1cead47b 100644 --- a/src/libexpr/include/nix/expr/eval.hh +++ b/src/libexpr/include/nix/expr/eval.hh @@ -474,7 +474,8 @@ private: LookupPath lookupPath; - boost::unordered_flat_map> lookupPathResolved; + boost::unordered_flat_map, StringViewHash, std::equal_to<>> + lookupPathResolved; /** * Cache used by prim_match(). @@ -751,8 +752,8 @@ public: boost::unordered_flat_map< std::string, Value *, - std::hash, - std::equal_to, + StringViewHash, + std::equal_to<>, traceable_allocator>> internalPrimOps; @@ -1019,7 +1020,7 @@ private: bool countCalls; - typedef boost::unordered_flat_map PrimOpCalls; + typedef boost::unordered_flat_map> PrimOpCalls; PrimOpCalls primOpCalls; typedef boost::unordered_flat_map FunctionCalls; diff --git a/src/libstore/gc.cc b/src/libstore/gc.cc index dd33f5f84..fdbc670df 100644 --- a/src/libstore/gc.cc +++ b/src/libstore/gc.cc @@ -311,7 +311,12 @@ Roots LocalStore::findRoots(bool censor) /** * Key is a mere string because cannot has path with macOS's libc++ */ -typedef boost::unordered_flat_map> UncheckedRoots; +typedef boost::unordered_flat_map< + std::string, + boost::unordered_flat_set>, + StringViewHash, + std::equal_to<>> + UncheckedRoots; static void readProcLink(const std::filesystem::path & file, UncheckedRoots & roots) { @@ -325,7 +330,7 @@ static void readProcLink(const std::filesystem::path & file, UncheckedRoots & ro throw; } if (buf.is_absolute()) - roots[buf.string()].emplace(file.string()); + roots[buf].emplace(file.string()); } static std::string quoteRegexChars(const std::string & raw) @@ -466,7 +471,7 @@ void LocalStore::collectGarbage(const GCOptions & options, GCResults & results) { // The temp roots only store the hash part to make it easier to // ignore suffixes like '.lock', '.chroot' and '.check'. - boost::unordered_flat_set tempRoots; + boost::unordered_flat_set> tempRoots; // Hash part of the store path currently being deleted, if // any. @@ -575,9 +580,9 @@ void LocalStore::collectGarbage(const GCOptions & options, GCResults & results) auto storePath = maybeParseStorePath(path); if (storePath) { debug("got new GC root '%s'", path); - auto hashPart = std::string(storePath->hashPart()); + auto hashPart = storePath->hashPart(); auto shared(_shared.lock()); - shared->tempRoots.insert(hashPart); + shared->tempRoots.emplace(hashPart); /* If this path is currently being deleted, then we have to wait until deletion is finished to ensure that @@ -629,7 +634,7 @@ void LocalStore::collectGarbage(const GCOptions & options, GCResults & results) Roots tempRoots; findTempRoots(tempRoots, true); for (auto & root : tempRoots) { - _shared.lock()->tempRoots.insert(std::string(root.first.hashPart())); + _shared.lock()->tempRoots.emplace(root.first.hashPart()); roots.insert(root.first); } @@ -736,7 +741,7 @@ void LocalStore::collectGarbage(const GCOptions & options, GCResults & results) return; { - auto hashPart = std::string(path->hashPart()); + auto hashPart = path->hashPart(); auto shared(_shared.lock()); if (shared->tempRoots.count(hashPart)) { debug("cannot delete '%s' because it's a temporary root", printStorePath(*path)); diff --git a/src/libstore/include/nix/store/gc-store.hh b/src/libstore/include/nix/store/gc-store.hh index fba9d6079..5a4a6db14 100644 --- a/src/libstore/include/nix/store/gc-store.hh +++ b/src/libstore/include/nix/store/gc-store.hh @@ -7,7 +7,11 @@ namespace nix { -typedef boost::unordered_flat_map, std::hash> Roots; +typedef boost::unordered_flat_map< + StorePath, + boost::unordered_flat_set>, + std::hash> + Roots; struct GCOptions {