From 19d9a87c2f513c6bfddb3c724cb365e878aeb601 Mon Sep 17 00:00:00 2001 From: Sergei Zimmerman Date: Tue, 12 Aug 2025 14:58:01 +0300 Subject: [PATCH] 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 --- lix/libexpr/primops/fromTOML.cc | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/lix/libexpr/primops/fromTOML.cc b/lix/libexpr/primops/fromTOML.cc index a27604271..c08334003 100644 --- a/lix/libexpr/primops/fromTOML.cc +++ b/lix/libexpr/primops/fromTOML.cc @@ -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(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);