Skip to content

Commit

Permalink
Speedup opam list on options that do not use availibility information
Browse files Browse the repository at this point in the history
  • Loading branch information
kit-ty-kate committed Aug 20, 2024
1 parent 562c984 commit df46f93
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 1 deletion.
1 change: 1 addition & 0 deletions master_changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ users)

## List
* ◈ Add a new `--latests-only` option to only list the latest packages [#5375 @kit-ty-kate]
* Speedup `opam list` on options that do not use availibility information [#5317 @kit-ty-kate - fix #5314]

## Show

Expand Down
3 changes: 2 additions & 1 deletion src/client/opamCommands.ml
Original file line number Diff line number Diff line change
Expand Up @@ -750,7 +750,8 @@ let list ?(force_search=false) cli =
let results =
OpamListCommand.filter ~base:all st filter
in
if not no_depexts && not silent then
if not no_depexts && not silent &&
OpamFormula.exists OpamListCommand.uses_depexts state_selector then
(let drop_by_depexts =
List.fold_left (fun missing str ->
let is_missing pkgs =
Expand Down
24 changes: 24 additions & 0 deletions src/client/opamListCommand.ml
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,30 @@ let pattern_selector patterns =
Atom (Pattern (version_patt, version))])
patterns)

let uses_depexts = function
| Any
| Installed
| Root
| Compiler
| Pinned
| Latests_only
| Pattern _
| Atoms _
| Flag _
| NotFlag _
| Tag _
| From_repository _
| Owns_file _
-> false
| Available
| Installable
| Depends_on _
| Required_by _
| Conflicts_with _
| Coinstallable_with _
| Solution _
-> true

let apply_selector ~base st = function
| Any -> base
| Installed -> st.installed
Expand Down
4 changes: 4 additions & 0 deletions src/client/opamListCommand.mli
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ type selector =
| From_repository of repository_name list
| Owns_file of filename

(** Returns [true] if the selector might require depexts availibility
information when applied using {!filter}. Returns [false] otherwise. *)
val uses_depexts : selector -> bool

(** Applies a formula of selectors to filter the package from a given switch
state *)
val filter:
Expand Down

0 comments on commit df46f93

Please sign in to comment.