From 3239903345b0a8a8de25aaf620680d516f681ca1 Mon Sep 17 00:00:00 2001 From: zazedd Date: Fri, 13 Sep 2024 16:07:53 +0100 Subject: [PATCH] Speed up `Store.last-modified` by comparing hashes instead of file contents --- src/irmin/store.ml | 10 +++++----- src/irmin/store_intf.ml | 5 ++--- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/irmin/store.ml b/src/irmin/store.ml index b73edf07bd..0fdff8565b 100644 --- a/src/irmin/store.ml +++ b/src/irmin/store.ml @@ -1153,9 +1153,9 @@ module Make (B : Backend.S) = struct let current, current_depth = Heap.pop_minimum heap in let parents = Commit.parents current in let tree = Commit.tree current in - let* current_value = Tree.find tree key in + let* current_tree = Tree.find_tree tree key in if List.length parents = 0 then - if current_value <> None then Lwt.return (current :: acc) + if current_tree <> None then Lwt.return (current :: acc) else Lwt.return acc else let max_depth = @@ -1173,9 +1173,9 @@ module Make (B : Backend.S) = struct Heap.add heap (commit, current_depth + 1) in let tree = Commit.tree commit in - let+ e = Tree.find tree key in - match (e, current_value) with - | Some x, Some y -> not (equal_contents x y) + let+ e = Tree.find_tree tree key in + match (e, current_tree) with + | Some x, Some y -> Tree.hash x <> Tree.hash y | Some _, None -> true | None, Some _ -> true | _, _ -> false) diff --git a/src/irmin/store_intf.ml b/src/irmin/store_intf.ml index 09ba421064..be708cf5a6 100644 --- a/src/irmin/store_intf.ml +++ b/src/irmin/store_intf.ml @@ -1006,10 +1006,9 @@ module type S_generic_key = sig head is not set) and stopping at [min] if specified. *) val last_modified : ?depth:int -> ?n:int -> t -> path -> commit list Lwt.t - (** [last_modified ?number c k] is the list of the last [number] commits that + (** [last_modified ?n c k] is the list of the last [n] commits that modified [path], in ascending order of date. [depth] is the maximum depth - to be explored in the commit graph, if any. Default value for [number] is - 1. *) + to be explored in the commit graph, if any. Default value for [n] is 1. *) (** Manipulate branches. *) module Branch : sig