libexpr: Use table.size() instead of unnecessary loop

(cherry picked from commit d8fc55a46e0c09241131097dbf1d6fa09e0a9808)
Upstream-PR: https://github.com/NixOS/nix/pull/13741
Change-Id: I8a11e21ae3bff3a885e13fbab74e1deb162a34cf
This commit is contained in:
Sergei Zimmerman
2025-08-16 01:20:12 +01:00
committed by Emily
parent 5badc1bc8a
commit 19d9a87c2f
+1 -8
View File
@@ -18,14 +18,7 @@ void prim_fromTOML(EvalState & state, Value ** args, Value & val)
switch (t.type()) {
case toml::value_t::table: {
auto table = toml::get<toml::table>(t);
size_t size = 0;
for (auto & i : table) {
(void) i;
size++;
}
auto attrs = state.ctx.buildBindings(size);
auto attrs = state.ctx.buildBindings(table.size());
for (auto & elem : table) {
self(attrs.alloc(elem.first), elem.second);