diff --git a/src/core/CCVector.ml b/src/core/CCVector.ml index 8ce99034..719ea85e 100644 --- a/src/core/CCVector.ml +++ b/src/core/CCVector.ml @@ -79,9 +79,13 @@ let init n f = { } (* is the underlying array empty? *) -let array_is_empty_ v = +let[@inline] array_is_empty_ v = Array.length v.vec = 0 +(* next capacity, if current one is [n] *) +let[@inline] next_grow_ n = + min Sys.max_array_length (n + n lsr 1 + 2) + (* resize the underlying array using x to temporarily fill the array *) let resize_ v newcapacity x = assert (newcapacity >= v.size); @@ -128,7 +132,7 @@ let grow_with_ v ~filler:x = fill_with_junk_ v.vec 0 len; ) else ( let n = Array.length v.vec in - let size = min (2 * n + 3) Sys.max_array_length in + let size = next_grow_ n in if size = n then invalid_arg "vec: can't grow any further"; resize_ v size v.vec.(0) ) @@ -143,8 +147,8 @@ let ensure_assuming_not_empty_ v ~size = ) else if size < Array.length v.vec then ( () (* nothing to do *) ) else ( - let n = ref (max 8 (Array.length v.vec)) in - while !n < size do n := min Sys.max_array_length (2* !n) done; + let n = ref (Array.length v.vec) in + while !n < size do n := next_grow_ !n done; resize_ v !n v.vec.(0) ) @@ -161,7 +165,7 @@ let ensure v size = ensure_assuming_not_empty_ v ~size ) -let clear v = +let[@inline] clear v = v.size <- 0 (*$R @@ -188,9 +192,9 @@ let clear_and_reset v = OUnit.assert_equal None (Weak.get a 0); *) -let is_empty v = v.size = 0 +let[@inline] is_empty v = v.size = 0 -let push_unsafe_ v x = +let[@inline] push_unsafe_ v x = Array.unsafe_set v.vec v.size x; v.size <- v.size + 1 @@ -296,11 +300,11 @@ let append a b = OUnit.assert_equal (Iter.to_array Iter.(6 -- 10)) (to_array b); *) -let get v i = +let[@inline] get v i = if i < 0 || i >= v.size then invalid_arg "CCVector.get"; Array.unsafe_get v.vec i -let set v i x = +let[@inline] set v i x = if i < 0 || i >= v.size then invalid_arg "CCVector.set"; Array.unsafe_set v.vec i x @@ -341,7 +345,7 @@ let remove_unordered v i = to_list v1 = (List.sort CCInt.compare (to_list v2))) *) -let append_iter a i = i (fun x -> push a x) +let[@inline] append_iter a i = i (fun x -> push a x) let append_seq a seq = Seq.iter (fun x -> push a x) seq @@ -477,12 +481,12 @@ let pop v = try Some (pop_exn v) with Empty -> None -let top v = - if v.size = 0 then None else Some v.vec.(v.size-1) +let[@inline] top v = + if v.size = 0 then None else Some (Array.unsafe_get v.vec (v.size-1)) -let top_exn v = +let[@inline] top_exn v = if v.size = 0 then raise Empty; - v.vec.(v.size-1) + Array.unsafe_get v.vec (v.size-1) (*$T 1 -- 10 |> top = Some 10 @@ -490,7 +494,7 @@ let top_exn v = 1 -- 10 |> top_exn = 10 *) -let copy v = { +let[@inline] copy v = { size = v.size; vec = Array.sub v.vec 0 v.size; } diff --git a/src/core/dune b/src/core/dune index d65c7d3f..ca13aa78 100644 --- a/src/core/dune +++ b/src/core/dune @@ -19,7 +19,6 @@ (modules :standard \ mkshims) (flags :standard -warn-error -a+8 -w -32 -safe-string -strict-sequence -nolabels -open CCMonomorphic) - (ocamlopt_flags (:include ../flambda.flags)) (libraries seq either containers.monomorphic)) (ocamllex (modules CCSexp_lex)) diff --git a/src/data/dune b/src/data/dune index 9e9ace90..7c5c1868 100644 --- a/src/data/dune +++ b/src/data/dune @@ -4,5 +4,4 @@ (public_name containers-data) (wrapped false) (flags :standard -w +a-4-42-44-48-50-58-32-60@8 -safe-string -open CCShims_) - (ocamlopt_flags :standard (:include ../flambda.flags)) (libraries containers)) diff --git a/src/dune b/src/dune index e7a035b6..21bb22a5 100644 --- a/src/dune +++ b/src/dune @@ -1,15 +1,10 @@ -(executable - (name mkflags) - (modules mkflags) - (libraries dune.configurator)) (env - (_ (flags :standard -warn-error -3))) - -(rule - (targets flambda.flags) - (mode fallback) - (action (run ./mkflags.exe))) + (_ + (flags :standard -warn-error -3 -color always) + (ocamlopt_flags :standard -O3 -unbox-closures -unbox-closures-factor 20 + -inline 100) + )) (executable (name mdx_runner) diff --git a/src/mkflags.ml b/src/mkflags.ml deleted file mode 100644 index 3c4ffca5..00000000 --- a/src/mkflags.ml +++ /dev/null @@ -1,19 +0,0 @@ - -module C = Configurator.V1 - -let () = - C.main ~name:"mkflags" (fun c -> - let version = C.ocaml_config_var_exn c "version" in - let major, minor = - Scanf.sscanf version "%u.%u" - (fun major minor -> major, minor) - in - let after_4_3 = (major, minor) >= (4, 3) in - let sexp = - if after_4_3 then ( - ["-O3"; "-unbox-closures"; "-unbox-closures-factor"; "20"; "-color"; "always"] - ) else ( - [] - ) in - C.Flags.write_sexp "flambda.flags" sexp - ) diff --git a/src/monomorphic/dune b/src/monomorphic/dune index 06b39722..c3a3bdbd 100644 --- a/src/monomorphic/dune +++ b/src/monomorphic/dune @@ -14,5 +14,4 @@ (public_name containers.monomorphic) (modules CCMonomorphic CCMonomorphicShims_) (wrapped false) - (flags :standard -w +a-4-42-44-48-50-58-32-60@8 -safe-string) - (ocamlopt_flags :standard (:include ../flambda.flags))) + (flags :standard -w +a-4-42-44-48-50-58-32-60@8 -safe-string)) diff --git a/src/threads/dune b/src/threads/dune index 55ce29ea..f27b5e65 100644 --- a/src/threads/dune +++ b/src/threads/dune @@ -5,6 +5,5 @@ (wrapped false) (optional) (flags :standard -warn-error -a+8 -w -32 -safe-string -open CCShims_) - (ocamlopt_flags :standard (:include ../flambda.flags)) (libraries containers threads)) diff --git a/src/top/dune b/src/top/dune index a23a99e7..29a6a6b4 100644 --- a/src/top/dune +++ b/src/top/dune @@ -5,5 +5,4 @@ (public_name containers.top) (wrapped false) (flags :standard -w +a-4-42-44-48-50-58-32-60@8 -safe-string) - (ocamlopt_flags :standard (:include ../flambda.flags)) (libraries compiler-libs.common containers containers.unix)) diff --git a/src/unix/dune b/src/unix/dune index bebb4ead..aa387981 100644 --- a/src/unix/dune +++ b/src/unix/dune @@ -5,6 +5,4 @@ (wrapped false) (optional) (flags :standard -w +a-4-42-44-48-50-58-32-60@8 -safe-string) - (ocamlopt_flags :standard (:include ../flambda.flags)) - (libraries unix) - ) + (libraries unix))