Skip to content

Commit

Permalink
Unroll version_rev_compare for performance purpose
Browse files Browse the repository at this point in the history
  • Loading branch information
kit-ty-kate committed Jul 30, 2024
1 parent c2e8428 commit 884aafa
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions lib-cudf/opam_0install_cudf.ml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,20 @@ let tagged_with_avoid_version pkg =
| _ -> false
) pkg.Cudf.pkg_extra

let version_rev_compare ~prefer_oldest pkg1 pkg2 =
let rev cmp = if prefer_oldest then cmp else -cmp in
match tagged_with_avoid_version pkg1, tagged_with_avoid_version pkg2 with
| true, true | false, false -> rev (Int.compare pkg1.Cudf.version pkg2.Cudf.version)
| true, false -> 1
| false, true -> -1
let version_rev_compare ~prefer_oldest =
(* Unrolled for performance purpose *)
if prefer_oldest then
fun pkg1 pkg2 ->
match tagged_with_avoid_version pkg1, tagged_with_avoid_version pkg2 with
| true, true | false, false -> Int.compare pkg1.Cudf.version pkg2.Cudf.version
| true, false -> 1
| false, true -> -1
else
fun pkg1 pkg2 ->
match tagged_with_avoid_version pkg1, tagged_with_avoid_version pkg2 with
| true, true | false, false -> Int.compare pkg2.Cudf.version pkg1.Cudf.version
| true, false -> 1
| false, true -> -1

module Context = struct
type rejection = UserConstraint of Cudf_types.vpkg
Expand Down

0 comments on commit 884aafa

Please sign in to comment.