From 3d4a6b9bb61850ff1fe699c5a757b1c0cc49f940 Mon Sep 17 00:00:00 2001 From: Tony Garnock-Jones Date: Tue, 23 Feb 2021 11:13:41 +0100 Subject: [PATCH] Tighten --- actor.ts | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/actor.ts b/actor.ts index 0a6de6f..c4f65f0 100644 --- a/actor.ts +++ b/actor.ts @@ -84,7 +84,12 @@ export class Turn { spawn(bootProc: (t: Turn) => void, initialAssertions = new IdentitySet()): void { this.tasks.push(() => { - const child = new Actor(extractFromMap(this.actor.outbound, initialAssertions)); + const newOutbound: OutboundMap = new Map(); + initialAssertions.forEach(key => { + newOutbound.set(key, this.actor.outbound.get(key)!); // we trust initialAssertions + this.actor.outbound.delete(key); + }); + const child = new Actor(newOutbound); child.execute(() => Turn.for(child, bootProc)); }); } @@ -137,12 +142,3 @@ export class Turn { this.tasks.length && queueMicrotask(() => this.tasks.forEach(f => Turn.for(this.actor, f))); } } - -function extractFromMap(map: Map, keys: IdentitySet): Map { - const result: Map = new Map(); - keys.forEach(key => { - if (map.has(key)) result.set(key, map.get(key)!); - map.delete(key); - }); - return result; -}