guix-patches
[Top][All Lists]
Advanced

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

[bug#49522] [PATCH] weather: Don't look for exported package replacement


From: Ludovic Courtès
Subject: [bug#49522] [PATCH] weather: Don't look for exported package replacements twice.
Date: Mon, 19 Jul 2021 19:10:55 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)

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’.





reply via email to

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