Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 2 additions & 26 deletions src/libexpr/include/nix/expr/symbol-table.hh
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,7 @@
#include "nix/util/error.hh"

#include <boost/version.hpp>
#define USE_FLAT_SYMBOL_SET (BOOST_VERSION >= 108100)
#if USE_FLAT_SYMBOL_SET
# include <boost/unordered/unordered_flat_set.hpp>
#else
# include <boost/unordered/unordered_set.hpp>
#endif
#include <boost/unordered/unordered_flat_set.hpp>

namespace nix {

Expand Down Expand Up @@ -214,12 +209,7 @@ private:
* Transparent lookup of string view for a pointer to a ChunkedVector entry -> return offset into the store.
* ChunkedVector references are never invalidated.
*/
#if USE_FLAT_SYMBOL_SET
boost::unordered_flat_set<SymbolStr, SymbolStr::Hash, SymbolStr::Equal> symbols{SymbolStr::chunkSize};
#else
using SymbolValueAlloc = std::pmr::polymorphic_allocator<SymbolStr>;
boost::unordered_set<SymbolStr, SymbolStr::Hash, SymbolStr::Equal, SymbolValueAlloc> symbols{SymbolStr::chunkSize, {&buffer}};
#endif

public:

Expand All @@ -230,19 +220,7 @@ public:
// Most symbols are looked up more than once, so we trade off insertion performance
// for lookup performance.
// FIXME: make this thread-safe.
return [&]<typename T>(T && key) -> Symbol {
if constexpr (requires { symbols.insert<T>(key); }) {
auto [it, _] = symbols.insert<T>(key);
return Symbol(*it);
} else {
auto it = symbols.find<T>(key);
if (it != symbols.end())
return Symbol(*it);

it = symbols.emplace(key).first;
return Symbol(*it);
}
}(SymbolStr::Key{store, s, stringAlloc});
return Symbol(*symbols.insert(SymbolStr::Key{store, s, stringAlloc}).first);
}

std::vector<SymbolStr> resolve(const std::vector<Symbol> & symbols) const
Expand Down Expand Up @@ -287,5 +265,3 @@ struct std::hash<nix::Symbol>
return std::hash<decltype(s.id)>{}(s.id);
}
};

#undef USE_FLAT_SYMBOL_SET
1 change: 1 addition & 0 deletions src/libutil/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ boost = dependency(
'boost',
modules : ['context', 'coroutine', 'iostreams'],
include_type: 'system',
version: '>=1.82.0'
)
# boost is a public dependency, but not a pkg-config dependency unfortunately, so we
# put in `deps_other`.
Expand Down
4 changes: 0 additions & 4 deletions src/libutil/serialise.cc
Original file line number Diff line number Diff line change
Expand Up @@ -194,10 +194,6 @@ size_t StringSource::read(char * data, size_t len)
}


#if BOOST_VERSION >= 106300 && BOOST_VERSION < 106600
#error Coroutines are broken in this version of Boost!
#endif
Comment on lines -197 to -199
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So please turn that into a src/libutil/meson.build somehow per the above, otherwise this looks good to me.


std::unique_ptr<FinishSink> sourceToSink(std::function<void(Source &)> fun)
{
struct SourceToSink : FinishSink
Expand Down
Loading