refactor(tvix): Use absl::btree_map for DerivationOutputs
This container implementation is much faster than std::map. We have stuck to an ordered container because it's unclear whether the accesses of this field (of which there are *many*) are actually ordering dependent. Also includes an Arbitrary implementation for absl::btree_map (for any K, V that are also Arbitrary). Change-Id: I04f58ca0ce32b9ae1759313b01508b0e44bae793 Reviewed-on: https://cl.tvl.fyi/c/depot/+/1683 Reviewed-by: glittershark <grfn@gws.fyi> Tested-by: BuildkiteCI
This commit is contained in:
parent
a41c3dedb1
commit
91bd7ce73a
4 changed files with 22 additions and 7 deletions
1
third_party/nix/src/tests/attr-set.cc
vendored
1
third_party/nix/src/tests/attr-set.cc
vendored
|
|
@ -5,6 +5,7 @@
|
|||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include <absl/container/btree_map.h>
|
||||
#include <bits/stdint-intn.h>
|
||||
#include <gc/gc_cpp.h>
|
||||
#include <gtest/gtest.h>
|
||||
|
|
|
|||
11
third_party/nix/src/tests/derivations_test.cc
vendored
11
third_party/nix/src/tests/derivations_test.cc
vendored
|
|
@ -22,6 +22,17 @@ namespace rc {
|
|||
using nix::Derivation;
|
||||
using nix::DerivationOutput;
|
||||
|
||||
template <class K, class V>
|
||||
struct Arbitrary<absl::btree_map<K, V>> {
|
||||
static Gen<absl::btree_map<K, V>> arbitrary() {
|
||||
return gen::map(gen::arbitrary<std::map<K, V>>(), [](std::map<K, V> map) {
|
||||
absl::btree_map<K, V> out_map;
|
||||
out_map.insert(map.begin(), map.end());
|
||||
return out_map;
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct Arbitrary<nix::Base> {
|
||||
static Gen<nix::Base> arbitrary() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue