From 66d32e0acb7ba13a18704e5d2abbd64d3cca95cb Mon Sep 17 00:00:00 2001 From: dzaima Date: Thu, 8 Sep 2022 00:47:25 +0300 Subject: [PATCH] =?UTF-8?q?fast=20exit=20for=20depth-2=20=F0=9D=95=A8=20in?= =?UTF-8?q?=20=F0=9D=95=A8=E2=8A=8F=F0=9D=95=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/builtins/select.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/builtins/select.c b/src/builtins/select.c index 5c3f48b6..981fb13f 100644 --- a/src/builtins/select.c +++ b/src/builtins/select.c @@ -159,6 +159,10 @@ B select_c2(B t, B w, B x) { #undef CASE #undef CASEW } else { + if (!elNum(TI(w,elType))) { // ๐•จ could be depth 2, in which case allocating the buffer isn't acceptable even temporarily + w = num_squeezeChk(w); + if (!elNum(TI(w,elType))) goto base; + } SLOW2("๐•จโŠ๐•ฉ", w, x); SGetU(w) ur wr = RNK(w); @@ -170,8 +174,7 @@ B select_c2(B t, B w, B x) { MAKE_MUT(r, wia*csz); mut_init(r, TI(x,elType)); MUTG_INIT(r); for (usz i = 0; i < wia; i++) { - B cw = GetU(w, i); - if (!isNum(cw)) { mut_pfree(r, i*csz); goto base; } + B cw = GetU(w, i); // assumed number from previous squeeze usz c = WRAP(o2i64(cw), cam, { mut_pfree(r, i*csz); thrF("โŠ: Indexing out-of-bounds (%RโˆŠ๐•จ, %sโ‰กโ‰ ๐•ฉ)", cw, cam); }); mut_copyG(r, i*csz, x, csz*c, csz); }