diff options
author | Keith Packard <keithp@keithp.com> | 2017-12-17 22:19:38 -0800 |
---|---|---|
committer | Keith Packard <keithp@keithp.com> | 2017-12-17 22:19:38 -0800 |
commit | 9d1131da911f7220ac8b6cb7ba5a0afd3deef657 (patch) | |
tree | 737dd7e127ab18e01cc844b63ae7dedb07e5c058 | |
parent | b866b3ca249dce61f8ff16c8d28514d1b80386d7 (diff) |
altos/scheme: Use AO_SCHEME_IS_CONS in cons memory funcs
More efficient than ao_scheme_poly_type as it doesn't care about
non-prim types.
Signed-off-by: Keith Packard <keithp@keithp.com>
-rw-r--r-- | src/scheme/ao_scheme.h | 1 | ||||
-rw-r--r-- | src/scheme/ao_scheme_cons.c | 6 |
2 files changed, 4 insertions, 3 deletions
diff --git a/src/scheme/ao_scheme.h b/src/scheme/ao_scheme.h index 521ec105..48d0149b 100644 --- a/src/scheme/ao_scheme.h +++ b/src/scheme/ao_scheme.h @@ -150,6 +150,7 @@ ao_scheme_is_const(ao_poly poly) { #define AO_SCHEME_IS_CONST(a) (ao_scheme_const <= ((uint8_t *) (a)) && ((uint8_t *) (a)) < ao_scheme_const + AO_SCHEME_POOL_CONST) #define AO_SCHEME_IS_POOL(a) (ao_scheme_pool <= ((uint8_t *) (a)) && ((uint8_t *) (a)) < ao_scheme_pool + AO_SCHEME_POOL) #define AO_SCHEME_IS_INT(p) (ao_scheme_poly_base_type(p) == AO_SCHEME_INT) +#define AO_SCHEME_IS_CONS(p) (ao_scheme_poly_base_type(p) == AO_SCHEME_CONS) void * ao_scheme_ref(ao_poly poly); diff --git a/src/scheme/ao_scheme_cons.c b/src/scheme/ao_scheme_cons.c index 02512e15..912100a9 100644 --- a/src/scheme/ao_scheme_cons.c +++ b/src/scheme/ao_scheme_cons.c @@ -24,8 +24,8 @@ static void cons_mark(void *addr) ao_scheme_poly_mark(cons->car, 1); if (!cdr) break; - if (ao_scheme_poly_type(cdr) != AO_SCHEME_CONS) { - ao_scheme_poly_mark(cdr, 1); + if (!AO_SCHEME_IS_CONS(cdr)) { + ao_scheme_poly_mark(cdr, 0); break; } cons = ao_scheme_poly_cons(cdr); @@ -58,7 +58,7 @@ static void cons_move(void *addr) cdr = cons->cdr; if (!cdr) break; - if (ao_scheme_poly_base_type(cdr) != AO_SCHEME_CONS) { + if (!AO_SCHEME_IS_CONS(cdr)) { (void) ao_scheme_poly_move(&cons->cdr, 0); break; } |