Skip to content

Commit afca10e

Browse files
committed
Avoid include of modules
1 parent 06e7bd0 commit afca10e

15 files changed

+32
-34
lines changed

lib/cmd.ml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ let duplicate kind name x _ =
1515
(name x |> replace_non_breaking_spaces))
1616

1717
let print_diff base next =
18-
List.zip_by
18+
List_ext.zip_by
1919
~duplicate:(duplicate "benchmark" Benchmark.name)
2020
String.compare Benchmark.name base next
2121
|> List.iter @@ fun ((base : Benchmark.t), (next : Benchmark.t)) ->
2222
Printf.printf "%s:\n" base.name;
2323
let zipped =
24-
List.zip_by
24+
List_ext.zip_by
2525
~duplicate:(duplicate "metric" Metric.name)
2626
String.compare Metric.name base.metrics next.metrics
2727
in
@@ -159,7 +159,7 @@ let run ~benchmarks ?(budgetf = 0.025) ?(filters = []) ?(debug = false)
159159
match base_results with
160160
| [] -> Fun.id
161161
| results ->
162-
let (module S) = Set.make String.compare in
162+
let (module S) = Set_ext.make String.compare in
163163
let names = results |> List.map Benchmark.name |> S.of_list in
164164
List.filter (fun (name, _) -> S.mem name names)
165165
end

lib/countdown.ml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,23 +38,23 @@ let non_atomic_set t count =
3838

3939
let rec get t count i =
4040
if i < Array.length t && Array.unsafe_get t i != Array.unsafe_get t 0 then
41-
get t (count + Int.max 0 (Atomic.get (Array.unsafe_get t i))) (i + 1)
41+
get t (count + Int_ext.max 0 (Atomic.get (Array.unsafe_get t i))) (i + 1)
4242
else count
4343

44-
let[@inline] get t = get t (Int.max 0 (Atomic.get (Array.unsafe_get t 0))) 1
44+
let[@inline] get t = get t (Int_ext.max 0 (Atomic.get (Array.unsafe_get t 0))) 1
4545

4646
let rec alloc t ~batch i =
4747
if i < Array.length t then
4848
let c = Array.unsafe_get t i in
4949
if 0 < Atomic.get c then
5050
let n = Atomic.fetch_and_add c (-batch) in
51-
if 0 < n then Int.min n batch else alloc t ~batch (i + 1)
51+
if 0 < n then Int_ext.min n batch else alloc t ~batch (i + 1)
5252
else alloc t ~batch (i + 1)
5353
else 0
5454

5555
let[@inline] alloc t ~domain_index ~batch =
5656
let c = Array.unsafe_get t domain_index in
5757
if 0 < Atomic.get c then
5858
let n = Atomic.fetch_and_add c (-batch) in
59-
if 0 < n then Int.min n batch else alloc t ~batch 0
59+
if 0 < n then Int_ext.min n batch else alloc t ~batch 0
6060
else alloc t ~batch 0

lib/data.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
open Option.Syntax
1+
open Option_ext.Syntax
22

33
module Trend = struct
44
type t = [ `Lower_is_better | `Higher_is_better ]

lib/dune

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,13 @@ let () =
1111
(enabled_if
1212
(< %{ocaml_version} 4.13.0))
1313
(action
14-
(copy int.ocaml_4_12.ml int.ml)))
14+
(copy int_ext.ocaml_lt_4_13.ml int_ext.ml)))
15+
16+
(rule
17+
(enabled_if
18+
(>= %{ocaml_version} 4.13.0))
19+
(action
20+
(copy int_ext.ocaml_ge_4_13.ml int_ext.ml)))
1521

1622
(library
1723
(public_name multicore-bench)

lib/int.ocaml_4_12.ml

Lines changed: 0 additions & 4 deletions
This file was deleted.

lib/int_ext.ocaml_ge_4_13.ml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
let min = Int.min
2+
let max = Int.max

lib/int_ext.ocaml_lt_4_13.ml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
let min (x : int) (y : int) = if x < y then x else y
2+
let max (x : int) (y : int) = if x < y then y else x

lib/json.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
open Option.Syntax
1+
open Option_ext.Syntax
22

33
type t = Yojson.Safe.t
44

lib/list.ml renamed to lib/list_ext.ml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
1-
include Stdlib.List
2-
31
let default_duplicate _ _ = invalid_arg "duplicate key"
42
let default_missing _ _ = None
53

64
let zip_by (type k) ?(duplicate = default_duplicate)
75
?(missing = default_missing) (compare : k -> _) key_of xs ys =
8-
let (module M) = Map.make compare in
6+
let (module M) = Map_ext.make compare in
97
let to_map xs =
108
xs
11-
|> fold_left
9+
|> List.fold_left
1210
(fun m x ->
1311
m
1412
|> M.update (key_of x) @@ function
@@ -24,4 +22,4 @@ let zip_by (type k) ?(duplicate = default_duplicate)
2422
| None, Some y -> missing `L y
2523
| None, None -> None)
2624
(to_map xs) (to_map ys)
27-
|> M.bindings |> map snd
25+
|> M.bindings |> List.map snd
Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
include Stdlib.Set
2-
31
let make (type t) (compare : t -> _) =
42
let (module Elt) = Ordered.make compare in
5-
(module Make (Elt) : Stdlib.Set.S with type elt = t)
3+
(module Map.Make (Elt) : Map.S with type key = t)

0 commit comments

Comments
 (0)