From d5597b4784e04020b4ef4968a6887d4e22cc3edd Mon Sep 17 00:00:00 2001 From: Griffin Smith Date: Sun, 12 Jul 2020 17:29:45 -0400 Subject: feat(3p/nix): Statically pass bindings capacity where possible To aid in making the decision of where to (currently just statically) use a vector or btree as the backing implementation, add an extra constructor argument to Bindings::NewGC for a capacity, and use a (currently hardcoded at 32, for no good reason other than it felt like a reasonable number) pivot to switch between our possible backing implementations. Then, update all the call sites where it feels reasonable that we know the capacity statically to *pass* that capacity to the constructor. Paired-With: Luke Granger-Brown Paired-With: Vincent Ambo Paired-With: Perry Lorier Change-Id: I1858c161301a1cd0e83aeeb9a58839378869e71d Reviewed-on: https://cl.tvl.fyi/c/depot/+/1124 Tested-by: BuildkiteCI Reviewed-by: lukegb Reviewed-by: isomer --- third_party/nix/src/libexpr/attr-set.hh | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'third_party/nix/src/libexpr/attr-set.hh') diff --git a/third_party/nix/src/libexpr/attr-set.hh b/third_party/nix/src/libexpr/attr-set.hh index 3834eac419e1..55641a020325 100644 --- a/third_party/nix/src/libexpr/attr-set.hh +++ b/third_party/nix/src/libexpr/attr-set.hh @@ -67,13 +67,9 @@ class Bindings { public: typedef BindingsIterator iterator; - // Allocate a new attribute set that is visible to the garbage - // collector. - static Bindings* NewGC(); - // Allocate a new attribute set with a static capacity that is visible to the // garbage collector. - // static Bindings* NewGC(size_t capacity); + static Bindings* NewGC(size_t capacity = 0); // Return the number of contained elements. virtual size_t size() = 0; -- cgit 1.4.1