From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Pip Cet Newsgroups: gmane.emacs.devel Subject: =?UTF-8?Q?Re=3A_master_b467bb5_4=2F4=3A_Minimize_=E2=80=98equal=E2=80=99_calls_i?= =?UTF-8?Q?n_=28delete_x_vector=29?= Date: Sat, 15 Aug 2020 19:00:09 +0000 Message-ID: References: <20200815181956.27401.76683@vcs0.savannah.gnu.org> <20200815181959.E7DC3209AC@vcs0.savannah.gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="32492"; mail-complaints-to="usenet@ciao.gmane.io" To: emacs-devel@gnu.org, Paul Eggert Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sat Aug 15 21:01:46 2020 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1k71R3-0008Mq-96 for ged-emacs-devel@m.gmane-mx.org; Sat, 15 Aug 2020 21:01:45 +0200 Original-Received: from localhost ([::1]:53140 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k71R2-0001cW-BW for ged-emacs-devel@m.gmane-mx.org; Sat, 15 Aug 2020 15:01:44 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:33470) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k71Q9-00019R-4P for emacs-devel@gnu.org; Sat, 15 Aug 2020 15:00:49 -0400 Original-Received: from mail-ot1-x333.google.com ([2607:f8b0:4864:20::333]:44291) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1k71Q7-0005BZ-Gg for emacs-devel@gnu.org; Sat, 15 Aug 2020 15:00:48 -0400 Original-Received: by mail-ot1-x333.google.com with SMTP id h22so10280337otq.11 for ; Sat, 15 Aug 2020 12:00:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :content-transfer-encoding; bh=pzJ3q7gOliU2fdKwmlKokKBrezelK0lc9Shss+GY1LA=; b=fwYXJ3v6m/052W0GgwrrqJp/q8d0OvAsIXo8mExTze+EGwgaS1l4cfSfjQ+kPlLzzu slJjq+7LdU54UDngeeVpQNDs/+ZveSBQ+4oqDjX5n1EcxpQo0kctm9iXfXzJPpWJpu4L yWabY87ZqWkjjMT2Awu132sbe89OzUinjAcpSlnNCwp7m6FBRQgZh2coVWApw1bNLFC7 OC/YAPZrrIUzAdvvgl2oTCo/CD1sM4D/DD5pCGz91WEKDD70USvu5UX5JnOc2JtDwclb 7FtvJhgdOoafA8AkrmShLHSJIJYW55A/kEswqUEkUCZk+XEtejNMVn1o8lER2+HUN7qF BsfQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:content-transfer-encoding; bh=pzJ3q7gOliU2fdKwmlKokKBrezelK0lc9Shss+GY1LA=; b=KAcUAm9hpxs/6pdUJNrZY6C64gLaYU0ojt8IwaZkLuXSOtr1lr0oU69Ir6230Cl20F fnlr91oWdQbkrZEVvD+3XStocycDiOt6aeme6REeBfPxPP/TTensFKlctpVe12KLdsYi c6XPMZZNL7RYDBXgPU/hmOOzU7ZEk0+2tN3j3U2sXIK8eWjXoDvk3fbGhlW41MttDXeG iOi34y2u8C+UHkO53zxmXtaaEQkq518/K46dXEGesS0Ce0ri3aL8Cmz16z603/zmbCxd vvHLp+kqRTjZWu94AktFZfRaeQp57Xo519cnNlA/0rEof4k6Njs8JpKEAjYuAY+CVrCj EJng== X-Gm-Message-State: AOAM530LizDMLfmt139hUAqkjWO1WBFLOB6fkF//fP0gVNABUTPNtPSf 5Hpk4zcpvGinw1LgMd8ZA6LWoZhQnbdc6mKZ4j/Y1bAD X-Google-Smtp-Source: ABdhPJwi7I4KR3VRJsR+HVhGx0zuKmtE4SNJ4PmqMnDr3PBlsGWeDyTazEBKtjVSAcLuIByFuOx5eVqSeN0zsw3uP7g= X-Received: by 2002:a9d:2c43:: with SMTP id f61mr6513503otb.154.1597518045502; Sat, 15 Aug 2020 12:00:45 -0700 (PDT) In-Reply-To: <20200815181959.E7DC3209AC@vcs0.savannah.gnu.org> Received-SPF: pass client-ip=2607:f8b0:4864:20::333; envelope-from=pipcet@gmail.com; helo=mail-ot1-x333.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:253816 Archived-At: On Sat, Aug 15, 2020 at 6:20 PM Paul Eggert wrote: > > branch: master > commit b467bb531e1ab0eed57e1889004d2115e80e4292 > Author: Paul Eggert > Commit: Paul Eggert > > Minimize =E2=80=98equal=E2=80=99 calls in (delete x vector) > > * src/fns.c (Fdelete): When deleting from a vector, call Fequal > only once per vector element. This is faster when Fequal is slow, > and avoids the need to preinitialize the vector result. Finish > when the result is exhausted, not when the input is exhausted; > the two are equivalent but the former may be faster. > * test/src/fns-tests.el (test-vector-delete): New test. > --- > src/fns.c | 38 +++++++++++++++++++++++++++++--------- > test/src/fns-tests.el | 5 +++++ > 2 files changed, 34 insertions(+), 9 deletions(-) > > diff --git a/src/fns.c b/src/fns.c > index c89bd81..069edbe 100644 > --- a/src/fns.c > +++ b/src/fns.c > @@ -1747,22 +1747,42 @@ changing the value of a sequence `foo'. */) > { > if (VECTORP (seq)) > { > - ptrdiff_t i, n; > + ptrdiff_t n =3D 0; > + ptrdiff_t size =3D ASIZE (seq); > + ptrdiff_t neqbits_words =3D ((size + BITS_PER_BITS_WORD - 1) > + / BITS_PER_BITS_WORD); > + USE_SAFE_ALLOCA; > + bits_word *neqbits =3D SAFE_ALLOCA (neqbits_words * sizeof *neqbit= s); > + bits_word neqword =3D 0; > > - for (i =3D n =3D 0; i < ASIZE (seq); ++i) > - if (NILP (Fequal (AREF (seq, i), elt))) > - ++n; This code looks wrong to me: > + for (ptrdiff_t i =3D 0; i < size; i++) > + { > + bool neq =3D NILP (Fequal (AREF (seq, i), elt)); > + n +=3D neq; > + neqbits[i / BITS_PER_BITS_WORD] =3D neqword =3D (neqword << 1) = + neq; > + } That left-shifts the first sequence element's bit left by up to 63 times. But ... > + for (ptrdiff_t i =3D 0; ; i++) > + if (neqbits[i / BITS_PER_BITS_WORD] > + & ((bits_word) 1 << (i % BITS_PER_BITS_WORD))) this checks the non-left-shifted LSB for the first sequence element. Indeed, we have (delete t [nil t]) =3D> [t] which is nonsensical.