diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2024-03-02 18:57:52 -0800 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2024-03-02 18:57:52 -0800 |
commit | 96c884c1754058cbacd709be0de17559c1a3a2a6 (patch) | |
tree | baae3ba39c6c462003df719d1ac0dec73658dde8 | |
parent | 06bd10fd45dc008fe0ea4909254b2e951e715809 (diff) | |
download | txr-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.c | 7 |
1 files changed, 4 insertions, 3 deletions
@@ -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) |