optimize: short-circuit update (//)
This commit is contained in:
@@ -270,6 +270,12 @@ export const op = {
|
|||||||
update: (a: NixValue, b: NixValue): NixAttrs => {
|
update: (a: NixValue, b: NixValue): NixAttrs => {
|
||||||
const mapA = forceAttrs(a);
|
const mapA = forceAttrs(a);
|
||||||
const mapB = forceAttrs(b);
|
const mapB = forceAttrs(b);
|
||||||
|
if (mapA.size === 0) {
|
||||||
|
return mapB;
|
||||||
|
}
|
||||||
|
if (mapB.size === 0) {
|
||||||
|
return mapA;
|
||||||
|
}
|
||||||
const result: NixAttrs = new Map(mapA);
|
const result: NixAttrs = new Map(mapA);
|
||||||
for (const [k, v] of mapB) {
|
for (const [k, v] of mapB) {
|
||||||
result.set(k, v);
|
result.set(k, v);
|
||||||
|
|||||||
Reference in New Issue
Block a user