summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2022-03-02 20:47:41 -0800
committerKaz Kylheku <kaz@kylheku.com>2022-03-02 20:47:41 -0800
commit8a664a3d518d8955155169e8f9637343f2208013 (patch)
treeba42bfaf30dc6e910abc42a83bf27fd0966b2b1d
parentcebfac5c3e8aeb555f3c424d3b46e6eb4348e2fe (diff)
downloadtxr-8a664a3d518d8955155169e8f9637343f2208013.tar.gz
txr-8a664a3d518d8955155169e8f9637343f2208013.tar.bz2
txr-8a664a3d518d8955155169e8f9637343f2208013.zip
hash: group-reduce calls hash-update.
* hash.c (group_reduce): Replace loop with call to hash_update which is exactly the same logic, and even more efficient because it avoids calling us_rplacd. (hash_update): Fix incorrect self name.
-rw-r--r--hash.c12
1 files changed, 3 insertions, 9 deletions
diff --git a/hash.c b/hash.c
index abefdf24..352f3f33 100644
--- a/hash.c
+++ b/hash.c
@@ -1701,14 +1701,8 @@ val group_reduce(val hash, val by_fun, val reduce_fun, val seq,
}
}
- if (!null_or_missing_p(filter_fun)) {
- struct hash_iter hi;
- val cell;
- hash_iter_init(&hi, hash, self);
-
- while ((cell = hash_iter_next(&hi)) != nil)
- us_rplacd(cell, funcall1(filter_fun, us_cdr(cell)));
- }
+ if (!null_or_missing_p(filter_fun))
+ hash_update(hash, filter_fun);
return hash;
}
@@ -1943,7 +1937,7 @@ val hash_proper_subset(val hash1, val hash2)
val hash_update(val hash, val fun)
{
- val self = lit("hash-subset");
+ val self = lit("hash-update");
val cell;
struct hash_iter hi;