[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: master 1559cc4: Fix missing file&line info in "Unknown defun propert

From: Stefan Monnier
Subject: Re: master 1559cc4: Fix missing file&line info in "Unknown defun property" warnings
Date: Sat, 23 Jan 2021 17:46:39 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

> 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)
    (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.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]