From: Pip Cet <pipcet@gmail.com>
To: emacs-devel@gnu.org, Paul Eggert <eggert@cs.ucla.edu>
Subject: Re: master b467bb5 4/4: Minimize ‘equal’ calls in (delete x vector)
Date: Sat, 15 Aug 2020 19:22:43 +0000 [thread overview]
Message-ID: <CAOqdjBfegY4RxnzcVgpnMfBRjSdC2W1Tfe83UNo8jy7sL+ubmg@mail.gmail.com> (raw)
In-Reply-To: <CAOqdjBc9RbLHYWje5cEJ6BEjvj+mnCUGMd9eo+P8NRi9g-ev+Q@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 265 bytes --]
On Sat, Aug 15, 2020 at 7:00 PM Pip Cet <pipcet@gmail.com> wrote:
> Indeed, we have
>
> (delete t [nil t]) => [t]
>
> which is nonsensical.
In fact, I'd prefer the attached: this is probably not worth worrying
too much about, so go with something straightforward?
[-- Attachment #2: 0001-Fix-delete-t-nil-t.patch --]
[-- Type: text/x-patch, Size: 1542 bytes --]
From 7e25be845efcb0ff6043b6100aaf81f6b8c9cafa Mon Sep 17 00:00:00 2001
From: Pip Cet <pipcet@gmail.com>
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
next prev parent reply other threads:[~2020-08-15 19:22 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20200815181956.27401.76683@vcs0.savannah.gnu.org>
[not found] ` <20200815181959.E7DC3209AC@vcs0.savannah.gnu.org>
2020-08-15 19:00 ` master b467bb5 4/4: Minimize ‘equal’ calls in (delete x vector) Pip Cet
2020-08-15 19:22 ` Pip Cet [this message]
2020-08-15 19:42 ` Paul Eggert
2020-08-15 20:21 ` Pip Cet
2020-08-16 0:49 ` Paul Eggert
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAOqdjBfegY4RxnzcVgpnMfBRjSdC2W1Tfe83UNo8jy7sL+ubmg@mail.gmail.com \
--to=pipcet@gmail.com \
--cc=eggert@cs.ucla.edu \
--cc=emacs-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.