From 58cd3c0c4b56cf9e65b7a532e7ecaa3b928a7091 Mon Sep 17 00:00:00 2001 From: Marshall Lochbaum Date: Wed, 12 Aug 2020 22:48:21 -0400 Subject: Minor optimizations to call() --- bqn.js | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/bqn.js b/bqn.js index 28436f5d..8f70176b 100644 --- a/bqn.js +++ b/bqn.js @@ -2,13 +2,10 @@ let assert = x => { if (!x) throw Error(); } let has = x => x!==undefined; let call = (f,x,w) => { - let ff = f; - if (typeof f === "function") { - assert(!f.m1&&!f.m2); - } else { - ff = ()=>f; - } - return !has(x) ? x : ff(x,w); + if (x===undefined) return x; + if (typeof f !== "function") return f; + assert(!f.m1&&!f.m2); + return f(x, w); } let get1= i => (v=>(assert(v!==null),v))(i[0][i[1]]); let get = i => i.a ? arr(i.map(get),i.sh) : get1(i); -- cgit v1.2.3