From 4246aa569460f7b60ef4463327b7cf0d76e5c1d5 Mon Sep 17 00:00:00 2001 From: dzaima Date: Sat, 18 Sep 2021 17:22:54 +0300 Subject: [PATCH] =?UTF-8?q?more=20reasonable=20=F0=9D=95=A8=E2=8D=8B?= =?UTF-8?q?=F0=9D=95=A9=20fallback?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/builtins/grade.h | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/builtins/grade.h b/src/builtins/grade.h index 3e02da3f..129c72b6 100644 --- a/src/builtins/grade.h +++ b/src/builtins/grade.h @@ -123,10 +123,15 @@ B GRADE_CAT(c2)(B t, B w, B x) { rp[i] = s; } } else { - SGetU(w) SGetU(x) + B* wp = arr_bptr(w); + if (wp==NULL) { + HArr* a = toHArr(w); + wp = a->a; + w = taga(a); + } if (CHECK_VALID && !FL_HAS(w,fl)) { - for (i64 i = 0; i < (i64)wia-1; i++) if (compare(GetU(w,i), GetU(w,i+1)) GRADE_UD(>,<) 0) thrM(GRADE_CHR": 𝕨 must be sorted"GRADE_UD(," in descending order")); + for (i64 i = 0; i < (i64)wia-1; i++) if (compare(wp[i], wp[i+1]) GRADE_UD(>,<) 0) thrM(GRADE_CHR": 𝕨 must be sorted"GRADE_UD(," in descending order")); FL_SET(w,fl); } @@ -135,7 +140,7 @@ B GRADE_CAT(c2)(B t, B w, B x) { usz s = 0, e = wia+1; while (e-s > 1) { usz m = (s+e) / 2; - if (compare(c, GetU(w,m-1)) GRADE_UD(<,>) 0) e = m; + if (compare(c, wp[m-1]) GRADE_UD(<,>) 0) e = m; else s = m; } rp[i] = s;