summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2024-03-02 18:57:52 -0800
committerKaz Kylheku <kaz@kylheku.com>2024-03-02 18:57:52 -0800
commit96c884c1754058cbacd709be0de17559c1a3a2a6 (patch)
treebaae3ba39c6c462003df719d1ac0dec73658dde8
parent06bd10fd45dc008fe0ea4909254b2e951e715809 (diff)
downloadtxr-96c884c1754058cbacd709be0de17559c1a3a2a6.tar.gz
txr-96c884c1754058cbacd709be0de17559c1a3a2a6.tar.bz2
txr-96c884c1754058cbacd709be0de17559c1a3a2a6.zip
unique: covert to seq_build.
* lib.c (unique): Build output using seq_build_t, rather than consing up a list which is then converted to the desired sequence type.
-rw-r--r--lib.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/lib.c b/lib.c
index 339fec2f..a1eb5881 100644
--- a/lib.c
+++ b/lib.c
@@ -11541,10 +11541,11 @@ val unique(val seq, val keyfun, varg hashv_args)
val hash = hashv(hashv_args);
val kf = default_arg(keyfun, identity_f);
seq_iter_t iter;
+ seq_build_t build;
val elem;
- list_collect_decl (out, ptail);
seq_iter_init(self, &iter, seq);
+ seq_build_init(self, &build, seq);
while (seq_get(&iter, &elem)) {
val new_p;
@@ -11552,10 +11553,10 @@ val unique(val seq, val keyfun, varg hashv_args)
(void) gethash_c(self, hash, funcall1(kf, elem), mkcloc(new_p));
if (new_p)
- ptail = list_collect(ptail, elem);
+ seq_add(&build, elem);
}
- return make_like(out, seq);
+ return seq_finish(&build);
}
val uniq(val seq)