From 4c0d535369cc3f335b4aaa24010e61a7de580dd4 Mon Sep 17 00:00:00 2001 From: Frederic Jung Date: Wed, 28 Oct 2026 20:18:06 +0100 Subject: [PATCH] Keep the cone carrier lookup out of compute() --- src/game/80-simulation/30-compute.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/game/80-simulation/30-compute.js b/src/game/80-simulation/30-compute.js index 0697cce..b69566c 100644 --- a/src/game/80-simulation/30-compute.js +++ b/src/game/80-simulation/30-compute.js @@ -1,5 +1,7 @@ // tr() with one placeholder, remembered: compute() labels every port, PNI and cache on every run. const LABS=new Map();function labOf(s,k,v){const key=s+'|'+v;let o=LABS.get(key);if(o===undefined)LABS.set(key,o=tr(s,{[k]:v}));return o;} +// Who carries a network reached only through a cone (kept out of compute(), whose size the JIT is sensitive to). +function coneBy(L,id){let by=null;for(const e of L){if(e.k==='p')return e.net;if(!by&&e.k==='ix'&&e.dir)by=ANC[id].find(u=>e.dir.has(u))||null;}return by||1;} function compute(){ const day=S.day, R2=emptyR(), pops=Object.keys(S.pops).filter(popUp), NC=CITIES.length; // The graph works on city indices: adj[i] lists [neighbour, edge] in S.links order. @@ -43,7 +45,7 @@ function compute(){ for(const n of NETS){R2.reachable[n.id]=okBy[n.id].some(e=>e.rank>0);if(R2.reachable[n.id])R2.reach+=NSH[n.id];if(okBy[n.id].some(e=>e.rank>0&&e.k!=='t')){R2.nt[n.id]=1;R2.reachNT+=NSH[n.id]; // Reached without transit only through the customers of networks you peer with (#85). R.cone[id]: the peer that // carries it, the first PNI's network or else the nearest upstream that is a member of an exchange you are on. - if(!okBy[n.id].some(e=>(e.k==='p'||e.k==='ix')&&!coneOf(e,n.id))){let by=null;for(const e of okBy[n.id]){if(e.k==='p'){by=e.net;break;}if(!by&&e.k==='ix'&&e.dir)by=ANC[n.id].find(u=>e.dir.has(u))||null;}R2.cone[n.id]=by||1;}}} + if(!okBy[n.id].some(e=>(e.k==='p'||e.k==='ix')&&!coneOf(e,n.id)))R2.cone[n.id]=coneBy(okBy[n.id],n.id);}} const cacheNets=new Set(S.caches.filter(c=>popUp(c.city)).map(c=>c.net)); const viral=(ev.viral>day?1.25:1)*(ev.php&&ev.php>day?0.7:1); // Every flow has the same shape and carries what routing asks about it again and again (nj: its network's index).