Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 5 additions & 9 deletions src/dune_rules/pkg_rules.ml
Original file line number Diff line number Diff line change
Expand Up @@ -498,18 +498,14 @@ module Pkg = struct
let contents = Fs_memo.Dir_contents.to_list contents in
List.rev_filter_partition_map contents ~f:(fun (name, kind) ->
(* TODO handle links and cycles correctly *)
let relative = Path.Local.relative path name in
match kind with
| S_DIR -> if skip_dir name then Skip else Right name
| _ -> if skip_file name then Skip else Left name)
in
let acc =
Path.Local.Set.of_list_map files ~f:(Path.Local.relative path)
|> Path.Local.Set.union acc
| S_DIR -> if skip_dir name then Skip else Right relative
Copy link
Copy Markdown
Collaborator

@Alizter Alizter Apr 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this if needs to be pulled out above the let releative. We always consider skipping, but we don't always need to construct relatative.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You mean something like this:

List.rev... ->
match kind with
| S_DIR -> if skip_dir name then Skip else Right (Path.Local.relative path name)
| _ -> if skip_file name then Skip else Left (Path.Local.relative path name))

It'd go against the idea of not repeating the relative call, for what I perceive to be minimal benefit

Did you miss that skip_dir and skip_file are different functions?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's true, my bad.

| _ -> if skip_file name then Skip else Left relative)
in
let acc = Path.Local.Set.of_list files |> Path.Local.Set.union acc in
let+ dirs =
Memo.parallel_map dirs ~f:(fun dir ->
let dir = Path.Local.relative path dir in
loop root Path.Local.Set.empty dir)
Memo.parallel_map dirs ~f:(fun dir -> loop root Path.Local.Set.empty dir)
in
Path.Local.Set.union_all (acc :: dirs)
in
Expand Down
Loading