From: Stefan Monnier <monnier@iro.umontreal.ca>
To: Philip Kaludercic <philipk@posteo.net>
Cc: Protesilaos Stavrou <info@protesilaos.com>, emacs-devel@gnu.org
Subject: Re: [elpa] main 2ec80977e1: * elpa-packages (dired-preview): New package
Date: Tue, 11 Jul 2023 09:33:14 -0400 [thread overview]
Message-ID: <jwvzg42egav.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <87v8eqc2k9.fsf@posteo.net> (Philip Kaludercic's message of "Tue, 11 Jul 2023 07:47:18 +0000")
>> I saw 'rx' a couple of times. I find it harder to use than the strings.
>> Though this is not a strong argument against it, I know.
>
> In this case, it would be
>
> --8<---------------cut here---------------start------------->8---
> (rx "." (or "mkv" "webm" "mp4" "mp3" "ogg" "m4a"
> "gz" "zst" "tar" "xz" "rar" "zip"
> "iso" "epub" "pdf"))
> --8<---------------cut here---------------end--------------->8---
>
> which seems fine to me? Fewer escape-sequences.
>
>>> "\\(mkv\\|webm\\|mp4\\|mp3\\|ogg\\|m4a"
>>> "\\|gz\\|zst\\|tar\\|xz\\|rar\\|zip"
>>> "\\|iso\\|epub\\|pdf\\)")
>>> "Regular expression of file type extensions to not preview."
>>> - :group 'dired-preview
>>> :type 'string)
BTW, you can most of the benefit here by using `regexp-opt` instead:
(concat "\\."
(regexp-opt "mkv" "webm" "mp4" "mp3" "ogg" "m4a"
"gz" "zst" "tar" "xz" "rar" "zip"
"iso" "epub" "pdf"))
> So unless you can make use of η-reduction, mapc incurs an overhead of
> a funcall overhead for each element, but had an advantage in that
> iteration happens in-core.
For the specific case at hand, there's also the cost of allocating the
closure and converting the free variable into a cons-cell (because it's
modified) which slows down accesses to it. IOW
(let ((size 0))
(mapc
(lambda (buffer)
(setq size (+ (buffer-size buffer) size)))
(dired-preview--get-buffers))
size))
will look somewhat like:
(let ((size (list 0)))
(mapc
(make-closure
(lambda (buffer)
(setcar V0 (+ (buffer-size buffer) (car V0))))
size)
(dired-preview--get-buffers))
(car size))
See bytecode below.
Stefan
byte code:
args: nil
0 constant 0
1 list1
2 constant mapc
3 constant make-closure
4 constant <compiled-function>
doc: ...
args: (arg1)
0 constant V0
1 constant buffer-size
2 stack-ref 2
3 call 1
4 constant V0
5 car-safe
6 plus
7 setcar
8 return
5 stack-ref 3
6 call 2
7 constant dired-preview--get-buffers
8 call 0
9 call 2
10 discard
11 car-safe
12 return
next prev parent reply other threads:[~2023-07-11 13:33 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <168884609732.27984.6450580686777461843@vcs2.savannah.gnu.org>
[not found] ` <20230708195457.95F1AC11DD8@vcs2.savannah.gnu.org>
2023-07-08 21:47 ` [elpa] main 2ec80977e1: * elpa-packages (dired-preview): New package Stefan Monnier
2023-07-09 2:29 ` Protesilaos Stavrou
2023-07-10 18:29 ` Philip Kaludercic
2023-07-10 20:20 ` Protesilaos Stavrou
2023-07-10 21:13 ` Stefan Monnier
2023-07-11 7:47 ` Philip Kaludercic
2023-07-11 13:33 ` Stefan Monnier [this message]
2023-07-11 16:58 ` Philip Kaludercic
2023-07-11 18:45 ` Stefan Monnier
2023-07-13 18:40 ` Protesilaos Stavrou
2023-07-13 20:29 ` Philip Kaludercic
2023-07-13 21:36 ` Stefan Monnier
2023-07-14 8:13 ` Mattias Engdegård
2023-07-14 14:18 ` [External] : " Drew Adams
2023-07-14 19:29 ` Philip Kaludercic
2023-07-18 19:06 ` Stefan Monnier
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=jwvzg42egav.fsf-monnier+emacs@gnu.org \
--to=monnier@iro.umontreal.ca \
--cc=emacs-devel@gnu.org \
--cc=info@protesilaos.com \
--cc=philipk@posteo.net \
/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.