optimize: short-circuit update (//)

This commit is contained in:
2026-02-19 21:54:49 +08:00
parent 4380fa85c4
commit b57fea3104

View File

@@ -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);