1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-11-16 07:22:43 +01:00

replace more std::unordered_* types by faster boost hash maps

This commit is contained in:
Philipp Otterbein 2025-09-06 14:21:48 +02:00 committed by Jörg Thalheim
parent 4f8c50fb77
commit 9f2b6a1b94
17 changed files with 75 additions and 71 deletions

View file

@ -258,7 +258,7 @@ public:
*/
std::string makeRelative(const CanonPath & path) const;
friend class std::hash<CanonPath>;
friend struct std::hash<CanonPath>;
};
std::ostream & operator<<(std::ostream & stream, const CanonPath & path);
@ -268,6 +268,8 @@ std::ostream & operator<<(std::ostream & stream, const CanonPath & path);
template<>
struct std::hash<nix::CanonPath>
{
using is_avalanching = std::true_type;
std::size_t operator()(const nix::CanonPath & s) const noexcept
{
return std::hash<std::string>{}(s.path);

View file

@ -4,10 +4,10 @@
#include "nix/util/file-system.hh"
#include "nix/util/finally.hh"
#include <boost/unordered/unordered_flat_set.hpp>
#include <chrono>
#include <cmath>
#include <regex>
#include <unordered_set>
#include <thread>
#include <dirent.h>
@ -76,7 +76,7 @@ static CgroupStats destroyCgroup(const std::filesystem::path & cgroup, bool retu
int round = 1;
std::unordered_set<pid_t> pidsShown;
boost::unordered_flat_set<pid_t> pidsShown;
while (true) {
auto pids = tokenizeString<std::vector<std::string>>(readFile(procsFile));

View file

@ -104,7 +104,7 @@ std::optional<struct stat> PosixSourceAccessor::cachedLstat(const CanonPath & pa
if (cache.size() >= 16384)
cache.clear();
cache.emplace(absPath, st);
cache.emplace(std::move(absPath), st);
return st;
}