about summary refs log tree commit diff
path: root/third_party/nix/src/libexpr/attr-set.hh
diff options
context:
space:
mode:
authorVincent Ambo <mail@tazj.in>2020-07-16T18·31+0100
committertazjin <mail@tazj.in>2020-07-16T18·51+0000
commitcb3d9675084f735c099c211edc4c8472f97a0578 (patch)
tree4888a8fdc264735fccca27ec86b25f5b69446724 /third_party/nix/src/libexpr/attr-set.hh
parent1ba5aa293bac0cd07421d5d1ba92c7fd8e2a5754 (diff)
refactor(3p/nix/libexpr): Use range insertion to merge nix::Bindings r/1320
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>
Diffstat (limited to 'third_party/nix/src/libexpr/attr-set.hh')
-rw-r--r--third_party/nix/src/libexpr/attr-set.hh10
1 files changed, 5 insertions, 5 deletions
diff --git a/third_party/nix/src/libexpr/attr-set.hh b/third_party/nix/src/libexpr/attr-set.hh
index f0b1448ba2f2..683b3e4bd75b 100644
--- a/third_party/nix/src/libexpr/attr-set.hh
+++ b/third_party/nix/src/libexpr/attr-set.hh
@@ -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();