From 7e25be845efcb0ff6043b6100aaf81f6b8c9cafa Mon Sep 17 00:00:00 2001 From: Pip Cet Date: Sat, 15 Aug 2020 19:20:27 +0000 Subject: [PATCH] Fix (delete t [nil t]). --- src/fns.c | 26 +++++--------------------- 1 file changed, 5 insertions(+), 21 deletions(-) diff --git a/src/fns.c b/src/fns.c index 069edbe90e..33c66aeef6 100644 --- a/src/fns.c +++ b/src/fns.c @@ -1749,35 +1749,19 @@ DEFUN ("delete", Fdelete, Sdelete, 2, 2, 0, { ptrdiff_t n = 0; ptrdiff_t size = ASIZE (seq); - ptrdiff_t neqbits_words = ((size + BITS_PER_BITS_WORD - 1) - / BITS_PER_BITS_WORD); USE_SAFE_ALLOCA; - bits_word *neqbits = SAFE_ALLOCA (neqbits_words * sizeof *neqbits); - bits_word neqword = 0; + ptrdiff_t *posns = SAFE_ALLOCA (size * sizeof posns[0]); for (ptrdiff_t i = 0; i < size; i++) - { - bool neq = NILP (Fequal (AREF (seq, i), elt)); - n += neq; - neqbits[i / BITS_PER_BITS_WORD] = neqword = (neqword << 1) + neq; - } + if (NILP (Fequal (AREF (seq, i), elt))) + posns[n++] = i; if (n != size) { struct Lisp_Vector *p = allocate_vector (n); - if (n != 0) - { - ptrdiff_t j = 0; - for (ptrdiff_t i = 0; ; i++) - if (neqbits[i / BITS_PER_BITS_WORD] - & ((bits_word) 1 << (i % BITS_PER_BITS_WORD))) - { - p->contents[j++] = AREF (seq, i); - if (j == n) - break; - } - } + for (ptrdiff_t j = 0; j < n; j++) + p->contents[j] = AREF (seq, posns[j]); XSETVECTOR (seq, p); } -- 2.28.0