diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2019-03-12 19:08:14 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2019-03-12 19:08:14 -0700 |
commit | 066a88f72be6063d9e8e9a6feb726ba017e2d675 (patch) | |
tree | 63839d6e98b26c466580aa3aeb906a9b9abfb907 /lib.h | |
parent | 3721f3acb4f2b1ac09e924590d27bb81db9b90ef (diff) | |
download | txr-066a88f72be6063d9e8e9a6feb726ba017e2d675.tar.gz txr-066a88f72be6063d9e8e9a6feb726ba017e2d675.tar.bz2 txr-066a88f72be6063d9e8e9a6feb726ba017e2d675.zip |
lib: optimize lazy functions with unchecked accesses.
* lib.h (us_lcons_fun): New inline function.
(us_cons_bind): New macro.
* eval.c (lazy_mapcar_func, lazy_mapcarv_func, range_func,
range_star_func, generate_func, giterate_func, ginterate_func,
expand_right_fun, repeat_infinite_func, repeat_times_func,
pad_func): Use us_cons_bind, us_car, us_cdr, us_rplaca,
us_rplacd and us_lazy_cons_func, which skip the type check.
* lib.c (lazy_conses_func, lazy_appendv_func, rem_lazy_func,
lazy_flatten_func, lazy_flatcar_fund, tuples_func,
partition_by_func, partition_func, split_func,
split_star_func, partition_star_func, lazy_interpose_fun,
take_list_fun, take_while_list_fun, take_until_list_fun,
lazy_where_has_func): Likewise.
Diffstat (limited to 'lib.h')
-rw-r--r-- | lib.h | 6 |
1 files changed, 6 insertions, 0 deletions
@@ -668,6 +668,7 @@ void rcyc_cons(val cons); void rcyc_list(val list); void rcyc_empty(void); val lcons_fun(val lcons); +INLINE val us_lcons_fun(val lcons) { return lcons->lc.func; } val list(val first, ...); /* terminated by nao */ val listv(struct args *); val consp(val obj); @@ -1225,6 +1226,11 @@ loc list_collect_revappend(loc ptail, val obj); obj_t *FROM = from(r_n_g ## FROM ## TO); \ obj_t *TO = ((r_n_g ## FROM ## TO)->rn.to) +#define us_cons_bind(CAR, CDR, CONS) \ + obj_t *c_o_n_s ## CAR ## CDR = CONS; \ + obj_t *CAR = us_car(c_o_n_s ## CAR ## CDR); \ + obj_t *CDR = us_cdr(c_o_n_s ## CAR ## CDR) + #define zero num_fast(0) #define one num_fast(1) #define two num_fast(2) |