deduplicate generic sort work
This commit is contained in:
parent
6e552fedf5
commit
c9be8516c3
@ -286,19 +286,10 @@ B GRADE_CAT(c1)(B t, B x) {
|
||||
if (elChr(xe)) { x = taga(cpyC32Arr(x)); goto el32; }
|
||||
|
||||
SLOW1(GRADE_CHR"𝕩", x);
|
||||
TALLOC(BI32p, tmp, ia);
|
||||
SGetU(x)
|
||||
for (usz i = 0; i < ia; i++) {
|
||||
tmp[i].v = i;
|
||||
tmp[i].k = GetU(x,i);
|
||||
}
|
||||
CAT(GRADE_CAT(BP),tim_sort)(tmp, ia);
|
||||
for (usz i = 0; i < ia; i++) rp[i] = tmp[i].v;
|
||||
TFREE(tmp);
|
||||
generic_grade(x, ia, r, rp, CAT(GRADE_CAT(BP),tim_sort));
|
||||
goto decG_sq;
|
||||
|
||||
decG_sq:;
|
||||
|
||||
if (ia<=(I8_MAX+1)) r = taga(cpyI8Arr(r));
|
||||
else if (ia<=(I16_MAX+1)) r = taga(cpyI16Arr(r));
|
||||
decG(x);
|
||||
|
||||
@ -8,6 +8,18 @@
|
||||
typedef struct BI32p { B k; i32 v; } BI32p;
|
||||
typedef struct I32I32p { i32 k; i32 v; } I32I32p;
|
||||
|
||||
static NOINLINE void generic_grade(B x, usz ia, B r, i32* rp, void (*fn)(BI32p*, size_t)) {
|
||||
TALLOC(BI32p, tmp, ia);
|
||||
SGetU(x)
|
||||
for (usz i = 0; i < ia; i++) {
|
||||
tmp[i].v = i;
|
||||
tmp[i].k = GetU(x,i);
|
||||
}
|
||||
fn(tmp, ia);
|
||||
for (usz i = 0; i < ia; i++) rp[i] = tmp[i].v;
|
||||
TFREE(tmp);
|
||||
}
|
||||
|
||||
#define GRADE_UD(U,D) U
|
||||
#include "grade.h"
|
||||
#define GRADE_UD(U,D) D
|
||||
|
||||
Loading…
Reference in New Issue
Block a user