mirror of
https://github.com/justinethier/cyclone.git
synced 2025-07-08 13:37:33 +02:00
Cleanup
This commit is contained in:
parent
4d7abf3b8c
commit
11f39e2b11
1 changed files with 7 additions and 13 deletions
16
runtime.c
16
runtime.c
|
@ -1244,34 +1244,28 @@ void Cyc_int2bignum(int n, mp_int *bn)
|
||||||
int Cyc_bignum_cmp(bn_cmp_type type, object x, int tx, object y, int ty)
|
int Cyc_bignum_cmp(bn_cmp_type type, object x, int tx, object y, int ty)
|
||||||
{
|
{
|
||||||
mp_int tmp;
|
mp_int tmp;
|
||||||
int cmp;
|
int cmp = 0;
|
||||||
|
|
||||||
if (tx == bignum_tag && ty == bignum_tag) {
|
if (tx == bignum_tag && ty == bignum_tag) {
|
||||||
cmp = mp_cmp(&bignum_value(x), &bignum_value(y));
|
cmp = mp_cmp(&bignum_value(x), &bignum_value(y));
|
||||||
return (cmp == type) ||
|
|
||||||
((type == CYC_BN_GTE && cmp > MP_LT) ||
|
|
||||||
(type == CYC_BN_LTE && cmp < MP_GT));
|
|
||||||
} else if (tx == bignum_tag && ty == -1) { \
|
} else if (tx == bignum_tag && ty == -1) { \
|
||||||
// TODO: could consolidate with below
|
|
||||||
// TODO: probably possible to use sign and if different can avoid bignum alloc
|
|
||||||
mp_init(&tmp);
|
mp_init(&tmp);
|
||||||
Cyc_int2bignum(obj_obj2int(y), &tmp);
|
Cyc_int2bignum(obj_obj2int(y), &tmp);
|
||||||
cmp = mp_cmp(&bignum_value(x), &tmp);
|
cmp = mp_cmp(&bignum_value(x), &tmp);
|
||||||
mp_clear(&tmp);
|
mp_clear(&tmp);
|
||||||
return (cmp == type) ||
|
|
||||||
((type == CYC_BN_GTE && cmp > MP_LT) ||
|
|
||||||
(type == CYC_BN_LTE && cmp < MP_GT));
|
|
||||||
} else if (tx == -1 && ty == bignum_tag) { \
|
} else if (tx == -1 && ty == bignum_tag) { \
|
||||||
mp_init(&tmp);
|
mp_init(&tmp);
|
||||||
Cyc_int2bignum(obj_obj2int(x), &tmp);
|
Cyc_int2bignum(obj_obj2int(x), &tmp);
|
||||||
cmp = mp_cmp(&tmp, &bignum_value(y));
|
cmp = mp_cmp(&tmp, &bignum_value(y));
|
||||||
mp_clear(&tmp);
|
mp_clear(&tmp);
|
||||||
|
} else {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
return (cmp == type) ||
|
return (cmp == type) ||
|
||||||
((type == CYC_BN_GTE && cmp > MP_LT) ||
|
((type == CYC_BN_GTE && cmp > MP_LT) ||
|
||||||
(type == CYC_BN_LTE && cmp < MP_GT));
|
(type == CYC_BN_LTE && cmp < MP_GT));
|
||||||
}
|
}
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
#define declare_num_cmp(FUNC, FUNC_OP, FUNC_FAST_OP, FUNC_APPLY, OP, BN_CMP) \
|
#define declare_num_cmp(FUNC, FUNC_OP, FUNC_FAST_OP, FUNC_APPLY, OP, BN_CMP) \
|
||||||
int FUNC_OP(void *data, object x, object y) { \
|
int FUNC_OP(void *data, object x, object y) { \
|
||||||
|
|
Loading…
Add table
Reference in a new issue