refactor(3p/nix/libexpr): Use range insertion to merge nix::Bindings
Instead of manually iterating over the two bindings to be combined, this adds a new static method on the Bindings class which merges two attribute sets by calling the range insertion operator over them. In some anecdotal tests, this can lead to a ~10% speed bump - depending on the specific operation. Change-Id: I5dea03b0589a83a789d3a8a0fc81d0d9e6598371 Reviewed-on: https://cl.tvl.fyi/c/depot/+/1216 Tested-by: BuildkiteCI Reviewed-by: glittershark <grfn@gws.fyi>
This commit is contained in:
parent
1ba5aa293b
commit
cb3d967508
3 changed files with 25 additions and 18 deletions
10
third_party/nix/src/libexpr/attr-set.hh
vendored
10
third_party/nix/src/libexpr/attr-set.hh
vendored
|
|
@ -36,8 +36,12 @@ class Bindings {
|
|||
// collector.
|
||||
static Bindings* NewGC(size_t capacity = 0);
|
||||
|
||||
// Create a new attribute set by merging two others. This is used to
|
||||
// implement the `//` operator in Nix.
|
||||
static Bindings* Merge(const Bindings& lhs, const Bindings& rhs);
|
||||
|
||||
// Return the number of contained elements.
|
||||
size_t size();
|
||||
size_t size() const;
|
||||
|
||||
// Is this attribute set empty?
|
||||
bool empty();
|
||||
|
|
@ -48,13 +52,9 @@ class Bindings {
|
|||
// Look up a specific element of the attribute set.
|
||||
iterator find(const Symbol& name);
|
||||
|
||||
// TODO
|
||||
iterator begin();
|
||||
iterator end();
|
||||
|
||||
// Merge values from other into this attribute set.
|
||||
void merge(const Bindings& other);
|
||||
|
||||
// TODO: can callers just iterate?
|
||||
[[deprecated]] std::vector<const Attr*> lexicographicOrder();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue