Skip to content
Open
Show file tree
Hide file tree
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
9 changes: 9 additions & 0 deletions otherlibs/stdune/src/path.ml
Original file line number Diff line number Diff line change
Expand Up @@ -946,6 +946,15 @@ module Table = struct
External.Table.iter external_ ~f
;;

let iteri { source; build; external_ } ~f =
Source0.Table.foldi source ~init:() ~f:(fun key data () ->
f ~key:(In_source_tree key) ~data);
Build.Table.foldi build ~init:() ~f:(fun key data () ->
f ~key:(In_build_dir key) ~data);
External.Table.foldi external_ ~init:() ~f:(fun key data () ->
f ~key:(External key) ~data)
;;

let[@inline] find { source; build; external_ } = function
| In_source_tree p -> Source0.Table.find source p
| In_build_dir p -> Build.Table.find build p
Expand Down
1 change: 1 addition & 0 deletions otherlibs/stdune/src/path.mli
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ module Table : sig
val set : 'a t -> path -> 'a -> unit
val remove : 'a t -> path -> unit
val iter : 'a t -> f:('a -> unit) -> unit
val iteri : 'a t -> f:(key:path -> data:'a -> unit) -> unit
val find : 'a t -> path -> 'a option
val filteri_inplace : 'a t -> f:(key:path -> data:'a -> bool) -> unit
val filter_inplace : 'a t -> f:('a -> bool) -> unit
Expand Down
4 changes: 1 addition & 3 deletions src/dune_engine/fs_memo.ml
Original file line number Diff line number Diff line change
Expand Up @@ -383,9 +383,7 @@ module Cached_digest = struct

let entries { table; _ } =
let entries = ref [] in
Path.Table.filteri_inplace table ~f:(fun ~key ~data ->
entries := (key, data) :: !entries;
true);
Path.Table.iteri table ~f:(fun ~key ~data -> entries := (key, data) :: !entries);
List.sort !entries ~compare:(fun (path_a, _) (path_b, _) ->
Path.compare path_a path_b)
;;
Expand Down
Loading