emacs-devel
[Top][All Lists]
Advanced

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

Re: [elpa] main 2ec80977e1: * elpa-packages (dired-preview): New package


From: Stefan Monnier
Subject: Re: [elpa] main 2ec80977e1: * elpa-packages (dired-preview): New package
Date: Mon, 10 Jul 2023 17:13:54 -0400
User-agent: Gnus/5.13 (Gnus v5.13)

>> -     (when (and (bufferp buffer)
>> -                (buffer-live-p buffer))
>> -       buffer))
>> +     (and (bufferp buffer)
>> +      (buffer-live-p buffer)))
>>     dired-preview--buffers))
>
> This is technically correct but more difficult to express intent.

BTW, `buffer-live-p` also accepts non-buffer arguments, so you can skip
the `bufferp` test.

>>    (let ((size 0))
>> -    (mapc
>> -     (lambda (buffer)
>> -       (setq size (+ (buffer-size buffer) size)))
>> -     (dired-preview--get-buffers))
>> +    (dolist (buffer (dired-preview--get-buffers))
>> +      (setq size (+ (buffer-size buffer) size)))
>>      size))
>
> Since we are here, what is the technical advantage of dolist over mapc?
> I have searched the docs for a clarification, but have not found one.  I
> get that it looks tidier, but is there a performance boost or something?

It's like an inlined mapc, which makes it a bit more efficient, yes.


        Stefan




reply via email to

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