unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
To: "Basil L. Contovounesios" <contovob@tcd.ie>
Cc: emacs-devel@gnu.org
Subject: Re: master 1559cc4: Fix missing file&line info in "Unknown defun property" warnings
Date: Sat, 23 Jan 2021 17:46:39 -0500	[thread overview]
Message-ID: <jwvwnw3nure.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <87y2gjz46n.fsf@tcd.ie> (Basil L. Contovounesios's message of "Sat, 23 Jan 2021 22:20:00 +0000")

> diff --git a/test/lisp/autorevert-tests.el b/test/lisp/autorevert-tests.el
> index 683e3ea30d..19d9f7b13f 100644
> --- a/test/lisp/autorevert-tests.el
> +++ b/test/lisp/autorevert-tests.el
> @@ -609,11 +609,12 @@ auto-revert-test07-auto-revert-several-buffers
>               (should auto-revert-mode))
 
>             (dotimes (i num-buffers)
> -             (add-to-list
> -              'buffers
> -              (make-indirect-buffer
> -               (car buffers) (format "%s-%d" (buffer-file-name (car buffers)) i) 'clone)
> -              'append))
> +             (let ((buf (make-indirect-buffer
> +                         (car buffers)
> +                         (format "%s-%d" (buffer-file-name (car buffers)) i)
> +                         'clone)))
> +               (unless (memq buf buffers)
> +                 (setq buffers (nconc buffers (list buf))))))

This looks like it will do what the old code did, yes.
We can do better, tho:

- the `make-indirect-buffer` will returna  fresh new buffer, so `memq`
  will always return nil.
- the `nconc` gives an over O(n²) complexity which is not justified.

so I'd recommend

    (dotimes (i num-buffers)
      (push (make-indirect-buffer
             (car buffers)
             (format "%s-%d" (buffer-file-name (car buffers)) i)
             'clone)
            buffers))
    (setq buffer (nreverse buffers))

instead.  I think the same applies to the second loop in autorevert-tests.el.

Also in `test-seq-random-elt-take-all` you can use `cl-pushnew` instead
of the or+memq+push.


        Stefan




  reply	other threads:[~2021-01-23 22:46 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20210123210445.12536.65283@vcs0.savannah.gnu.org>
     [not found] ` <20210123210447.45FA120AD1@vcs0.savannah.gnu.org>
2021-01-23 22:20   ` master 1559cc4: Fix missing file&line info in "Unknown defun property" warnings Basil L. Contovounesios
2021-01-23 22:46     ` Stefan Monnier [this message]
2021-01-23 23:42       ` Basil L. Contovounesios

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

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=jwvwnw3nure.fsf-monnier+emacs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=contovob@tcd.ie \
    --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 public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).