diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2019-11-01 20:27:42 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2019-11-01 20:27:42 -0700 |
commit | 1a71176dca92298cbb4e93530be2a79c80956471 (patch) | |
tree | 67c9b7e0d943cf26f89776b58c3b5060ed48f073 /eval.c | |
parent | fcd748480a76b3fef7586483b29fc5281e405e1f (diff) | |
download | txr-1a71176dca92298cbb4e93530be2a79c80956471.tar.gz txr-1a71176dca92298cbb4e93530be2a79c80956471.tar.bz2 txr-1a71176dca92298cbb4e93530be2a79c80956471.zip |
lib: use stack-allocated hash iterators everywhere.
* eval.c (op_dohash): Use hash_iter instead of consing up
heap-allocated hash iterator.
* filter.c (trie_compress, regex_from_trie): Likewise.
* hash.c (hash_equal_op, hash_hash_op, hash_print_op):
Likewise.
* lib.c (package_local_symbols, package_foreign_symbols,
find_max, find_if, rfind_if, populate_obj_hash): Likewise.
* parser.c (circ_backpatch, get_visible_syms): Likewise.
* struct.c (method_name, get_slot_syms): Likewise.
Diffstat (limited to 'eval.c')
-rw-r--r-- | eval.c | 7 |
1 files changed, 5 insertions, 2 deletions
@@ -2488,21 +2488,24 @@ static val op_for(val form, val env) static val op_dohash(val form, val env) { + val op = first(form); val spec = second(form); val keysym = first(spec); val valsym = second(spec); val hashform = third(spec); val resform = fourth(spec); val body = rest(rest(form)); - val iter = hash_begin(eval(hashform, env, hashform)); val keyvar = cons(keysym, nil); val valvar = cons(valsym, nil); val new_env = make_env(cons(keyvar, cons(valvar, nil)), nil, env); val cell; + struct hash_iter hi; + + hash_iter_init(&hi, eval(hashform, env, hashform), op); uw_block_begin (nil, result); - while ((cell = hash_next(iter)) != nil) { + while ((cell = hash_iter_next(&hi)) != nil) { /* These assignments are gc-safe, because keyvar and valvar are newer objects than existing entries in the hash, unless the body mutates hash by inserting newer objects, |