From 38671e3fe9f5264455cbed8bcdee36b12dbd7d36 Mon Sep 17 00:00:00 2001 From: Marshall Lochbaum Date: Wed, 5 Jul 2023 07:32:49 -0400 Subject: [PATCH] =?UTF-8?q?Fast=20handling=20for=20length-1=20=F0=9D=95=A8?= =?UTF-8?q?=20in=20Bins?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/builtins/grade.h | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/src/builtins/grade.h b/src/builtins/grade.h index 1021f477..8b78b522 100644 --- a/src/builtins/grade.h +++ b/src/builtins/grade.h @@ -362,6 +362,8 @@ bool CAT(isSorted,GRADE_UD(Up,Down))(B x) { #undef CMP } +extern B CAT(GRADE_UD(le,ge),c2)(B,B,B); + B GRADE_CAT(c2)(B t, B w, B x) { if (isAtm(w) || RNK(w)==0) thrM(GRADE_CHR": 𝕨 must have rank≥1"); if (isAtm(x)) x = m_unit(x); @@ -378,9 +380,29 @@ B GRADE_CAT(c2)(B t, B w, B x) { u8 we = TI(w,elType); usz wia = IA(w); u8 xe = TI(x,elType); usz xia = IA(x); + B r; if (wia==0 | xia==0) { Arr* ra=allZeroes(xia); arr_shCopy(ra, x); - decG(w); decG(x); return taga(ra); + r=taga(ra); goto done; + } + if (wia==1) { + B c = IGet(w, 0); + if (LIKELY(weI32_MAX-10) thrM(GRADE_CHR": 𝕨 too big"); @@ -390,7 +412,6 @@ B GRADE_CAT(c2)(B t, B w, B x) { FL_SET(w, fl); } - B r; if (LIKELY(we