From: "Ludovic Courtès" <ludo@gnu.org>
To: Christopher Baines <mail@cbaines.net>
Cc: 49522@debbugs.gnu.org
Subject: [bug#49522] [PATCH] weather: Don't look for exported package replacements twice.
Date: Mon, 19 Jul 2021 19:10:55 +0200 [thread overview]
Message-ID: <875yx6mdpc.fsf@gnu.org> (raw)
In-Reply-To: <20210711115638.30207-1-mail@cbaines.net> (Christopher Baines's message of "Sun, 11 Jul 2021 12:56:38 +0100")
Hi!
Christopher Baines <mail@cbaines.net> skribis:
> There could be performance issues with member here, but only if there are lots
> of replacements.
>
> * guix/scripts/weather.scm (all-packages): Return all exported packages, plus
> non exported replacements, rather than including exported replacements twice.
[...]
> + "Return the list of packages we are going to query."
> + (let* ((packages
> + (fold-packages (lambda (package result)
> + (cons package result))
> + '()
> +
> + ;; Dismiss deprecated packages but keep hidden packages.
> + #:select? (negate package-superseded)))
> + (non-exported-replacement-packages
> + (fold-packages (lambda (package result)
> + (let ((replacement (package-replacement package)))
> + (if (and replacement
> + ;; Avoid double couting replacements
> + ;; that are themselves exported
> + (not (member replacement packages)))
> + (cons replacement result)
> + result)))
> + '()
> +
> + ;; Dismiss deprecated packages but keep hidden packages.
> + #:select? (negate package-superseded))))
> + (append
> + packages
> + non-exported-replacement-packages)))
Is the goal to delete duplicates?
In that case, how about wrapping the existing expression in
(delete-duplicates … eq?) ?
(Note that (member x lst) is O(N) is the number of packages, so the code
above is quadratic in the number of packages, which should be avoided.
Also, packages cannot be meaningfully compared with ‘equal?’ (which is
expensive in case of different packages), so ‘eq?’ should be preferred.)
Thanks,
Ludo’.
next prev parent reply other threads:[~2021-07-19 17:12 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-11 11:56 [bug#49522] [PATCH] weather: Don't look for exported package replacements twice Christopher Baines
2021-07-19 17:10 ` Ludovic Courtès [this message]
2021-08-01 15:01 ` Christopher Baines
2021-08-01 15:45 ` Christopher Baines
2021-09-01 21:30 ` Ludovic Courtès
2021-09-03 9:25 ` bug#49522: " Christopher Baines
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://guix.gnu.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=875yx6mdpc.fsf@gnu.org \
--to=ludo@gnu.org \
--cc=49522@debbugs.gnu.org \
--cc=mail@cbaines.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 public inbox
https://git.savannah.gnu.org/cgit/guix.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).