1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-11-11 21:16:02 +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

@ -4571,11 +4571,13 @@ struct RegexCache
std::regex regex;
/* No std::regex constructor overload from std::string_view, but can be constructed
from a pointer + size or an iterator range. */
cache.try_emplace_and_cvisit(re,
/*s=*/re.data(), /*count=*/re.size(), std::regex::extended,
cache.try_emplace_and_cvisit(
re,
/*s=*/re.data(),
/*count=*/re.size(),
std::regex::extended,
[&regex](const auto & kv) { regex = kv.second; },
[&regex](const auto & kv) { regex = kv.second; }
);
[&regex](const auto & kv) { regex = kv.second; });
return regex;
}
};

View file

@ -1,5 +1,4 @@
#include <limits>
#include <unordered_set>
#include <sstream>
#include "nix/expr/print.hh"
@ -10,6 +9,8 @@
#include "nix/util/english.hh"
#include "nix/expr/eval.hh"
#include <boost/unordered/unordered_flat_set.hpp>
namespace nix {
void printElided(
@ -81,7 +82,7 @@ std::ostream & printLiteralBool(std::ostream & str, bool boolean)
// For example `or' doesn't need to be quoted.
bool isReservedKeyword(const std::string_view str)
{
static const std::unordered_set<std::string_view> reservedKeywords = {
static const boost::unordered_flat_set<std::string_view> reservedKeywords = {
"if", "then", "else", "assert", "with", "let", "in", "rec", "inherit"};
return reservedKeywords.contains(str);
}