mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-25 23:36:16 +02:00
Remove unused boost include and split out std-hash.hh
Splitting it out immediately answers questions like [this], without increasing the number of compilation units. I did consider using boost::hash_combine instead, but it doesn't seem to be quite as capable, accepting only two arguments. [this]: https://github.com/NixOS/nix/pull/11113#discussion_r1679991573
This commit is contained in:
parent
64b46000ad
commit
d0e9878389
5 changed files with 27 additions and 17 deletions
|
@ -2,7 +2,7 @@
|
|||
|
||||
#include <cinttypes>
|
||||
|
||||
#include "util.hh"
|
||||
#include "std-hash.hh"
|
||||
|
||||
namespace nix {
|
||||
|
||||
|
|
|
@ -216,6 +216,7 @@ headers = [config_h] + files(
|
|||
'source-accessor.hh',
|
||||
'source-path.hh',
|
||||
'split.hh',
|
||||
'std-hash.hh',
|
||||
'strings.hh',
|
||||
'strings-inline.hh',
|
||||
'suggestions.hh',
|
||||
|
|
|
@ -8,8 +8,7 @@
|
|||
#include "ref.hh"
|
||||
#include "canon-path.hh"
|
||||
#include "source-accessor.hh"
|
||||
|
||||
#include <boost/functional/hash.hpp> // for boost::hash_combine
|
||||
#include "std-hash.hh"
|
||||
|
||||
namespace nix {
|
||||
|
||||
|
|
24
src/libutil/std-hash.hh
Normal file
24
src/libutil/std-hash.hh
Normal file
|
@ -0,0 +1,24 @@
|
|||
#pragma once
|
||||
|
||||
//!@file Hashing utilities for use with unordered_map, etc. (ie low level implementation logic, not domain logic like
|
||||
//! Nix hashing)
|
||||
|
||||
#include <functional>
|
||||
|
||||
namespace nix {
|
||||
|
||||
/**
|
||||
* hash_combine() from Boost. Hash several hashable values together
|
||||
* into a single hash.
|
||||
*/
|
||||
inline void hash_combine(std::size_t & seed) {}
|
||||
|
||||
template<typename T, typename... Rest>
|
||||
inline void hash_combine(std::size_t & seed, const T & v, Rest... rest)
|
||||
{
|
||||
std::hash<T> hasher;
|
||||
seed ^= hasher(v) + 0x9e3779b9 + (seed << 6) + (seed >> 2);
|
||||
hash_combine(seed, rest...);
|
||||
}
|
||||
|
||||
} // namespace nix
|
|
@ -375,18 +375,4 @@ inline std::string operator + (std::string_view s1, const char * s2)
|
|||
return s;
|
||||
}
|
||||
|
||||
/**
|
||||
* hash_combine() from Boost. Hash several hashable values together
|
||||
* into a single hash.
|
||||
*/
|
||||
inline void hash_combine(std::size_t & seed) { }
|
||||
|
||||
template <typename T, typename... Rest>
|
||||
inline void hash_combine(std::size_t & seed, const T & v, Rest... rest)
|
||||
{
|
||||
std::hash<T> hasher;
|
||||
seed ^= hasher(v) + 0x9e3779b9 + (seed<<6) + (seed>>2);
|
||||
hash_combine(seed, rest...);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue