Skip to content

Commit

Permalink
fix(engine): small optimization for Patch_back_source_tree sandboxes (#…
Browse files Browse the repository at this point in the history
…8938)

We don't need to [stat] directories when snapshotting the sandbox in
[Patch_back_source_tree].

Signed-off-by: Rudi Grinberg <[email protected]>
  • Loading branch information
rgrinberg authored Oct 18, 2023
1 parent cff3d36 commit 88314d3
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/dune_engine/sandbox.ml
Original file line number Diff line number Diff line change
Expand Up @@ -158,14 +158,14 @@ let snapshot t =
(* CR-someday jeremiedimino: we do this kind of traversal in other places.
Might be worth trying to factorise the code. *)
let rec walk dir acc =
match Path.Untracked.readdir_unsorted dir with
match Path.Untracked.readdir_unsorted_with_kinds dir with
| Error (err, func, arg) -> raise (Unix.Unix_error (err, func, arg))
| Ok files ->
List.fold_left files ~init:acc ~f:(fun acc basename ->
List.fold_left files ~init:acc ~f:(fun acc (basename, (kind : Unix.file_kind)) ->
let p = Path.relative dir basename in
let stats = Path.Untracked.lstat_exn p in
match stats.st_kind with
match kind with
| S_REG ->
let stats = Path.Untracked.lstat_exn p in
Path.Map.add_exn acc p (Cached_digest.Reduced_stats.of_unix_stats stats)
| S_DIR -> walk p acc
| _ -> acc)
Expand Down

0 comments on commit 88314d3

Please sign in to comment.