diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2019-02-14 07:44:35 -0800 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2019-02-14 07:44:35 -0800 |
commit | 2ab6f0183ba2fb014cc028aeb8afb6a2aba7c059 (patch) | |
tree | 37e1126e0ebfff351489ba63ee9cda8ef5e670b9 /parser.c | |
parent | ee7866ae60fe4357bbcd453dbfdf5a90528dda7b (diff) | |
download | txr-2ab6f0183ba2fb014cc028aeb8afb6a2aba7c059.tar.gz txr-2ab6f0183ba2fb014cc028aeb8afb6a2aba7c059.tar.bz2 txr-2ab6f0183ba2fb014cc028aeb8afb6a2aba7c059.zip |
Optimize hash operation with unsafe car/cdr.
The associative lists that make up the chains of a hash table
are guaranteed to be made of conses. We can use unsafe
versions of car, cdr, rplaca and rplacd to speed up hash
operations.
* eval.c (op_dohash): Use unsafe operations on hash cell.
* filter.c (trie_compress, regex_from_trie): Likewise.
* hash.c (hash_equal_op, hash_print_op, hash_mark, hash_grow,
hash_assoc, hash_assql, copy_hash_chain, gethash, inhash,
gethash_n, sethash, remhash, hash_next, maphash,
do_weak_tables, group_by, group_reduce, hash_keys_lazy,
hash_keys, hash_values_lazy, hash_values, hash_pairs_lazy,
hash_pairs, hash_alist_lazy, hash_uni, hash_diff,
hash_symdiff, hash_isec, hash_subset, hash_update,
hash_update_1, hash_revget): Likewise.
* lib.c (us_rplaca, us_rplacd): New functions.
(package_local_symbols, package_foreign_symbols, where,
populate_obj_hash, obj_hash_merge): Use unsafe operations on
hash cell
* lib.h (us_rplaca, us_rplacd): Declared.
* parser.c (circ_backpatch, get_visible_syms): Use unsafe
operations on hash cell.
* struct.c (method_name, get_slot_syms): Likewise.
Diffstat (limited to 'parser.c')
-rw-r--r-- | parser.c | 6 |
1 files changed, 3 insertions, 3 deletions
@@ -339,7 +339,7 @@ tail: while (pairs) { val cell = pop(&pairs); - sethash(obj, car(cell), cdr(cell)); + sethash(obj, us_car(cell), us_cdr(cell)); } } } else if (structp(obj)) { @@ -743,9 +743,9 @@ static val get_visible_syms(val package, int include_fallback) val fcell; val new_p; while ((fcell = hash_next(hiter))) { - loc pcdr = gethash_l(lit("listener"), symhash, car(fcell), mkcloc(new_p)); + loc pcdr = gethash_l(lit("listener"), symhash, us_car(fcell), mkcloc(new_p)); if (new_p) - set(pcdr, cdr(fcell)); + set(pcdr, us_cdr(fcell)); } } return hash_values(symhash); |