From b57fea31046cd542bb54eb1d7a6a8329f6744de9 Mon Sep 17 00:00:00 2001 From: imxyy_soope_ Date: Thu, 19 Feb 2026 21:54:49 +0800 Subject: [PATCH] optimize: short-circuit update (//) --- nix-js/runtime-ts/src/operators.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/nix-js/runtime-ts/src/operators.ts b/nix-js/runtime-ts/src/operators.ts index 4f47724..75ab841 100644 --- a/nix-js/runtime-ts/src/operators.ts +++ b/nix-js/runtime-ts/src/operators.ts @@ -270,6 +270,12 @@ export const op = { update: (a: NixValue, b: NixValue): NixAttrs => { const mapA = forceAttrs(a); const mapB = forceAttrs(b); + if (mapA.size === 0) { + return mapB; + } + if (mapB.size === 0) { + return mapA; + } const result: NixAttrs = new Map(mapA); for (const [k, v] of mapB) { result.set(k, v);