From 51a09295bc9f6ac3ffdacb1eb51858a6331c6f02 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Wed, 2 Mar 2022 20:47:41 -0800 Subject: 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. --- hash.c | 12 +++--------- 1 file 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; -- cgit v1.2.3