···165165- #4070, #10398: small optimization of Stdlib.{frexp,modf}.
166166 (Markus Mottl, Nicolás Ojeda Bär, review by Gabriel Scherer)
167167168168+- #10389, #10391, #10392: Add {Int,Int32,Int64,Nativeint}.{min,max}.
169169+ (Nicolás Ojeda Bär and Alain Frisch, review by Xavier Leroy)
170170+168171### Other libraries:
169172170173- #10047: Add `Unix.realpath`
+1-1
asmcomp/branch_relaxation.ml
···130130 let rec relax f ~max_out_of_line_code_offset =
131131 let min_of_max_branch_offsets =
132132 List.fold_left (fun min_of_max_branch_offsets branch ->
133133- min min_of_max_branch_offsets
133133+ Int.min min_of_max_branch_offsets
134134 (T.Cond_branch.max_displacement branch))
135135 max_int T.Cond_branch.all
136136 in
+1-1
asmcomp/coloring.ml
···7777 if not (Reg.is_visited r) then begin
7878 Reg.mark_visited r;
7979 f r w;
8080- List.iter (fun (r1, w1) -> walk r1 (min w w1)) r.prefer
8080+ List.iter (fun (r1, w1) -> walk r1 (Int.min w w1)) r.prefer
8181 end in
8282 List.iter (fun (r, w) -> walk r w) reg.prefer;
8383 Reg.clear_visited_marks () in
+4-4
asmcomp/emitaux.ml
···7474 end else begin
7575 let i = ref 0 in
7676 while !i < l do
7777- let n = min (l - !i) 80 in
7777+ let n = Int.min (l - !i) 80 in
7878 emit_string directive;
7979 emit_string_literal (String.sub s !i n);
8080 emit_char '\n';
···248248 a.efa_string defname
249249 in
250250 let pack_info fd_raise d has_next =
251251- let line = min 0xFFFFF d.Debuginfo.dinfo_line
252252- and char_start = min 0xFF d.Debuginfo.dinfo_char_start
253253- and char_end = min 0x3FF d.Debuginfo.dinfo_char_end
251251+ let line = Int.min 0xFFFFF d.Debuginfo.dinfo_line
252252+ and char_start = Int.min 0xFF d.Debuginfo.dinfo_char_start
253253+ and char_end = Int.min 0x3FF d.Debuginfo.dinfo_char_end
254254 and kind = if fd_raise then 1 else 0
255255 and has_next = if has_next then 1 else 0 in
256256 Int64.(add (shift_left (of_int line) 44)
+1-1
asmcomp/schedgen.ml
···121121 node.length <-
122122 List.fold_left
123123 (fun len (son, delay) ->
124124- max len (longest_path critical_outputs son + delay))
124124+ Int.max len (longest_path critical_outputs son + delay))
125125 0 sons
126126 end;
127127 node.length
+1-1
asmcomp/selectgen.ml
···570570 self#insert env (Iop Imove) [|src|] [|dst|]
571571572572method insert_moves env src dst =
573573- for i = 0 to min (Array.length src) (Array.length dst) - 1 do
573573+ for i = 0 to Stdlib.Int.min (Array.length src) (Array.length dst) - 1 do
574574 self#insert_move env src.(i) dst.(i)
575575 done
576576
+2-2
asmcomp/spill.ml
···169169 let date_ifso = !current_date in
170170 current_date := date_fork;
171171 let (new_ifnot, after_ifnot) = reload ifnot at_fork in
172172- current_date := max date_ifso !current_date;
172172+ current_date := Int.max date_ifso !current_date;
173173 let (new_next, finally) =
174174 reload i.next (Reg.Set.union after_ifso after_ifnot) in
175175 let new_i =
···189189 current_date := date_fork;
190190 let (new_c, after_c) = reload c at_fork in
191191 after_cases := Reg.Set.union !after_cases after_c;
192192- date_join := max !date_join !current_date;
192192+ date_join := Int.max !date_join !current_date;
193193 new_c)
194194 cases in
195195 current_date := !date_join;
···506506 let
507507 {c_time = t} = find_checkpoint_before (pre64 time_max)
508508 in
509509- go_to (max time t);
509509+ go_to (Int64.max time t);
510510 let (new_time, break) = find_last_breakpoint time_max in
511511 if break <> None || (new_time <= time) then begin
512512 go_to new_time;
···520520let step_backward duration =
521521 let time = current_time () in
522522 if time > _0 then
523523- back_to (max _0 (time -- duration)) time
523523+ back_to (Int64.max _0 (time -- duration)) time
524524525525(* Run the program from current time. *)
526526(* Stop at the first breakpoint, or at the end of the program. *)
+2-2
lambda/simplif.ml
···113113 match Hashtbl.find_opt exits i with
114114 | Some r ->
115115 r.count <- r.count + nb;
116116- r.max_depth <- max r.max_depth d
116116+ r.max_depth <- Int.max r.max_depth d
117117 | None ->
118118 let r = {count = nb; max_depth = d} in
119119 Hashtbl.add exits i r
···155155 increases j's ref count *)
156156 count ~try_depth l1 ;
157157 let ic = get_exit i in
158158- incr_exit j ic.count (max try_depth ic.max_depth)
158158+ incr_exit j ic.count (Int.max try_depth ic.max_depth)
159159 | Lstaticcatch(l1, (i,_), l2) ->
160160 count ~try_depth l1;
161161 (* If l1 does not contain (exit i),
+1-1
lex/common.ml
···5555let copy_chars_unix ic oc start stop =
5656 let n = ref (stop - start) in
5757 while !n > 0 do
5858- let m = input ic copy_buffer 0 (min !n 1024) in
5858+ let m = input ic copy_buffer 0 (Int.min !n 1024) in
5959 output oc copy_buffer 0 m;
6060 n := !n - m
6161 done
+2-2
lex/cset.ml
···5555 else if c2' < c1 then
5656 inter l r'
5757 else if c2 < c2' then
5858- (max c1 c1', c2)::inter r l'
5858+ (Int.max c1 c1', c2)::inter r l'
5959 else
6060- (max c1 c1', c2')::inter l r'
6060+ (Int.max c1 c1', c2')::inter l r'
61616262let rec diff l l' = match l, l' with
6363 _, [] -> l
+1-1
lex/lexgen.ml
···494494 Alt(reg, Seq(r, Action count)),
495495 (count, m ,act) :: actions,
496496 (succ count),
497497- max loc_ntags ntags)
497497+ Int.max loc_ntags ntags)
498498 (Empty, [], 0, 0)
499499 casedef in
500500 r
+1-1
middle_end/flambda/flambda_to_clambda.ml
···428428 List.iter
429429 (fun (key, lam) ->
430430 index.(key) <- store.act_store () lam;
431431- smallest_key := min key !smallest_key
431431+ smallest_key := Int.min key !smallest_key
432432 )
433433 cases;
434434 if !smallest_key < num_keys then begin
+2-2
middle_end/flambda/inline_and_simplify_aux.ml
···333333 try
334334 Closure_origin.Map.find id t.inlining_counts
335335 with Not_found ->
336336- max 1 (Clflags.Int_arg_helper.get
336336+ Int.max 1 (Clflags.Int_arg_helper.get
337337 ~key:t.round !Clflags.inline_max_unroll)
338338 in
339339 inlining_count > 0
···343343 try
344344 Closure_origin.Map.find id t.inlining_counts
345345 with Not_found ->
346346- max 1 (Clflags.Int_arg_helper.get
346346+ Int.max 1 (Clflags.Int_arg_helper.get
347347 ~key:t.round !Clflags.inline_max_unroll)
348348 in
349349 let inlining_counts =
+3-3
middle_end/flambda/inlining_cost.ml
···172172 | Never_inline, _ -> Never_inline
173173 | _, Never_inline -> Never_inline
174174 | Can_inline_if_no_larger_than i1, Can_inline_if_no_larger_than i2 ->
175175- Can_inline_if_no_larger_than (min i1 i2)
175175+ Can_inline_if_no_larger_than (Int.min i1 i2)
176176177177 let equal t1 t2 =
178178 match t1, t2 with
···674674 let inline_call_cost = cost !Clflags.inline_call_cost ~round in
675675 direct_call_size + (inline_call_cost * benefit_factor)
676676 in
677677- max_cost := max !max_cost max_size
677677+ max_cost := Int.max !max_cost max_size
678678 done;
679679 !max_cost
680680 end
···687687 let inline_prim_cost = cost !Clflags.inline_prim_cost ~round in
688688 inline_prim_cost * benefit_factor
689689 in
690690- max_cost := max !max_cost max_size
690690+ max_cost := Int.max !max_cost max_size
691691 done;
692692 !max_cost
693693 end
+4-4
ocamldoc/odoc_dag2html.ml
···228228 next_l next_j;
229229 flush stderr
230230 end;
231231- let next_l = min next_l next_j in
231231+ let next_l = Int.min next_l next_j in
232232 let colspan = 3 * (next_l - l) - 2 in
233233 let les =
234234 match t.table.(i).(l).elem, t.table.(i + 1).(l).elem with
···343343 match get_block t i (j + 1) with
344344 Some ((x1, c1) :: list, mpc, span) ->
345345 let (list, mpc) =
346346- if x1 = x.elem then (x1, c1 + 1) :: list, max mpc (c1 + 1)
347347- else (x.elem, 1) :: (x1, c1) :: list, max mpc c1
346346+ if x1 = x.elem then (x1, c1 + 1) :: list, Int.max mpc (c1 + 1)
347347+ else (x.elem, 1) :: (x1, c1) :: list, Int.max mpc c1
348348 in
349349 Some (list, mpc, span)
350350 | _ -> assert false
···753753 in
754754 if nii <> ii || njj1 <> jj1 || njj2 <> jj2 || njj3 <> jj3 ||
755755 njj4 <> jj4 then
756756- let nii = min ii nii in
756756+ let nii = Int.min ii nii in
757757 let (jj1, jj2, jj3, jj4) =
758758 find_linked_children t nii njj1 njj2 njj3 njj4
759759 in
+1-1
ocamltest/ocamltest_stdlib.ml
···183183 let copy_chan ic oc =
184184 let m = in_channel_length ic in
185185 let m = (m lsr 12) lsl 12 in
186186- let m = max 16384 (min Sys.max_string_length m) in
186186+ let m = Int.max 16384 (Int.min Sys.max_string_length m) in
187187 let buf = Bytes.create m in
188188 let rec loop () =
189189 let len = input ic buf 0 m in
···3636STDLIB_MODULE_BASENAMES=\
3737 camlinternalFormatBasics camlinternalAtomic \
3838 stdlib pervasives seq option either result bool char uchar \
3939- sys list bytes string unit marshal obj array float int int32 int64 nativeint \
3939+ sys list int bytes string unit marshal obj array float int32 int64 nativeint \
4040 lexing parsing set map stack queue camlinternalLazy lazy stream buffer \
4141 camlinternalFormat printf arg atomic \
4242 printexc fun gc digest random hashtbl weak \
+4-4
stdlib/arg.ml
···339339340340let max_arg_len cur (kwd, spec, doc) =
341341 match spec with
342342- | Symbol _ -> max cur (String.length kwd)
343343- | _ -> max cur (String.length kwd + second_word doc)
342342+ | Symbol _ -> Int.max cur (String.length kwd)
343343+ | _ -> Int.max cur (String.length kwd + second_word doc)
344344345345346346let replace_leading_tab s =
···355355 ksd
356356 | (kwd, (Symbol _ as spec), msg) ->
357357 let cutcol = second_word msg in
358358- let spaces = String.make ((max 0 (len - cutcol)) + 3) ' ' in
358358+ let spaces = String.make ((Int.max 0 (len - cutcol)) + 3) ' ' in
359359 (kwd, spec, "\n" ^ spaces ^ replace_leading_tab msg)
360360 | (kwd, spec, msg) ->
361361 let cutcol = second_word msg in
···373373let align ?(limit=max_int) speclist =
374374 let completed = add_help speclist in
375375 let len = List.fold_left max_arg_len 0 completed in
376376- let len = min len limit in
376376+ let len = Int.min len limit in
377377 List.map (add_padding len) completed
378378379379let trim_cr s =
+2-2
stdlib/bytes.ml
···8484 let len = length s ++ left ++ right in
8585 let r = create len in
8686 let (srcoff, dstoff) = if left < 0 then -left, 0 else 0, left in
8787- let cpylen = min (length s - srcoff) (len - dstoff) in
8787+ let cpylen = Int.min (length s - srcoff) (len - dstoff) in
8888 if cpylen > 0 then unsafe_blit s srcoff r dstoff cpylen;
8989 r
9090···418418 let buf = ref (make 256 '\000') in
419419 let resize () =
420420 (* resize *)
421421- let new_len = min (2 * length !buf) Sys.max_string_length in
421421+ let new_len = Int.min (2 * length !buf) Sys.max_string_length in
422422 if length !buf = new_len then failwith "Bytes.of_seq: cannot grow bytes";
423423 let new_buf = make new_len '\000' in
424424 blit !buf 0 new_buf 0 !n;
+1-1
stdlib/camlinternalFormat.ml
···260260 let len = Bytes.length buf.bytes in
261261 let min_len = buf.ind + overhead in
262262 if min_len > len then (
263263- let new_len = max (len * 2) min_len in
263263+ let new_len = Int.max (len * 2) min_len in
264264 let new_str = Bytes.create new_len in
265265 Bytes.blit buf.bytes 0 new_str 0 len;
266266 buf.bytes <- new_str;
+4-2
stdlib/ephemeron.ml
···345345346346 let stats h =
347347 let mbl =
348348- Array.fold_left (fun m b -> max m (bucket_length 0 b)) 0 h.data in
348348+ Array.fold_left (fun m b -> Int.max m (bucket_length 0 b)) 0 h.data in
349349 let histo = Array.make (mbl + 1) 0 in
350350 Array.iter
351351 (fun b ->
···366366 let stats_alive h =
367367 let size = ref 0 in
368368 let mbl =
369369- Array.fold_left (fun m b -> max m (bucket_length_alive 0 b)) 0 h.data in
369369+ Array.fold_left
370370+ (fun m b -> Int.max m (bucket_length_alive 0 b)) 0 h.data
371371+ in
370372 let histo = Array.make (mbl + 1) 0 in
371373 Array.iter
372374 (fun b ->
+2-2
stdlib/format.ml
···270270 state.pp_is_new_line <- true;
271271 let indent = state.pp_margin - width + offset in
272272 (* Don't indent more than pp_max_indent. *)
273273- let real_indent = min state.pp_max_indent indent in
273273+ let real_indent = Int.min state.pp_max_indent indent in
274274 state.pp_current_indent <- real_indent;
275275 state.pp_space_left <- state.pp_margin - state.pp_current_indent;
276276 pp_output_indent state state.pp_current_indent;
···806806 (* If possible maintain pp_min_space_left to its actual value,
807807 if this leads to a too small max_indent, take half of the
808808 new margin, if it is greater than 1. *)
809809- max (max (state.pp_margin - state.pp_min_space_left)
809809+ Int.max (Int.max (state.pp_margin - state.pp_min_space_left)
810810 (state.pp_margin / 2)) 1 in
811811 (* Rebuild invariants. *)
812812 pp_set_max_indent state new_max_indent
+1-1
stdlib/hashtbl.ml
···236236237237let stats h =
238238 let mbl =
239239- Array.fold_left (fun m b -> max m (bucket_length 0 b)) 0 h.data in
239239+ Array.fold_left (fun m b -> Int.max m (bucket_length 0 b)) 0 h.data in
240240 let histo = Array.make (mbl + 1) 0 in
241241 Array.iter
242242 (fun b ->
+2
stdlib/int.ml
···3838external shift_right_logical : int -> int -> int = "%lsrint"
3939let equal : int -> int -> bool = ( = )
4040let compare : int -> int -> int = Stdlib.compare
4141+let min x y : t = if x <= y then x else y
4242+let max x y : t = if x >= y then x else y
4143external to_float : int -> float = "%floatofint"
4244external of_float : float -> int = "%intoffloat"
4345
+10
stdlib/int.mli
···108108val compare : int -> int -> int
109109(** [compare x y] is {!Stdlib.compare}[ x y] but more efficient. *)
110110111111+val min : int -> int -> int
112112+(** Return the smaller of the two arguments.
113113+ @since 4.13.0
114114+*)
115115+116116+val max : int -> int -> int
117117+(** Return the greater of the two arguments.
118118+ @since 4.13.0
119119+ *)
120120+111121(** {1:convert Converting} *)
112122113123external to_float : int -> float = "%floatofint"
+3
stdlib/int32.ml
···8686let unsigned_compare n m =
8787 compare (sub n min_int) (sub m min_int)
88888989+let min x y : t = if x <= y then x else y
9090+let max x y : t = if x >= y then x else y
9191+8992(* Unsigned division from signed division of the same
9093 bitness. See Warren Jr., Henry S. (2013). Hacker's Delight (2 ed.), Sec 9-3.
9194*)
+11
stdlib/int32.mli
···215215(** The equal function for int32s.
216216 @since 4.03.0 *)
217217218218+val min: t -> t -> t
219219+(** Return the smaller of the two arguments.
220220+ @since 4.13.0
221221+*)
222222+223223+val max: t -> t -> t
224224+(** Return the greater of the two arguments.
225225+ @since 4.13.0
226226+ *)
227227+228228+218229(**/**)
219230220231(** {1 Deprecated functions} *)
+3
stdlib/int64.ml
···8585let unsigned_compare n m =
8686 compare (sub n min_int) (sub m min_int)
87878888+let min x y : t = if x <= y then x else y
8989+let max x y : t = if x >= y then x else y
9090+8891(* Unsigned division from signed division of the same
8992 bitness. See Warren Jr., Henry S. (2013). Hacker's Delight (2 ed.), Sec 9-3.
9093*)
+10
stdlib/int64.mli
···234234(** The equal function for int64s.
235235 @since 4.03.0 *)
236236237237+val min: t -> t -> t
238238+(** Return the smaller of the two arguments.
239239+ @since 4.13.0
240240+*)
241241+242242+val max: t -> t -> t
243243+(** Return the greater of the two arguments.
244244+ @since 4.13.0
245245+ *)
246246+237247(**/**)
238248239249(** {1 Deprecated functions} *)
+1-2
stdlib/lexing.ml
···8080 end;
8181 result
82828383-8483let lex_refill read_fun aux_buffer lexbuf =
8584 let read =
8685 read_fun aux_buffer (Bytes.length aux_buffer) in
···109108 space since n <= String.length aux_buffer <= String.length buffer.
110109 Watch out for string length overflow, though. *)
111110 let newlen =
112112- min (2 * Bytes.length lexbuf.lex_buffer) Sys.max_string_length in
111111+ Int.min (2 * Bytes.length lexbuf.lex_buffer) Sys.max_string_length in
113112 if lexbuf.lex_buffer_len - lexbuf.lex_start_pos + n > newlen
114113 then failwith "Lexing.lex_refill: cannot grow buffer";
115114 let newbuf = Bytes.create newlen in
+3
stdlib/nativeint.ml
···7575let unsigned_compare n m =
7676 compare (sub n min_int) (sub m min_int)
77777878+let min x y : t = if x <= y then x else y
7979+let max x y : t = if x >= y then x else y
8080+7881(* Unsigned division from signed division of the same
7982 bitness. See Warren Jr., Henry S. (2013). Hacker's Delight (2 ed.), Sec 9-3.
8083*)
+11
stdlib/nativeint.mli
···225225(** The equal function for native ints.
226226 @since 4.03.0 *)
227227228228+val min: t -> t -> t
229229+(** Return the smaller of the two arguments.
230230+ @since 4.13.0
231231+*)
232232+233233+val max: t -> t -> t
234234+(** Return the greater of the two arguments.
235235+ @since 4.13.0
236236+ *)
237237+238238+228239(**/**)
229240230241(** {1 Deprecated functions} *)
+1-1
stdlib/random.ml
···4949 s.st.(i) <- i;
5050 done;
5151 let accu = ref "x" in
5252- for i = 0 to 54 + max 55 l do
5252+ for i = 0 to 54 + Int.max 55 l do
5353 let j = i mod 55 in
5454 let k = i mod l in
5555 accu := combine !accu seed.(k);
+4-4
stdlib/scanf.ml
···808808 match c with
809809 | '.' ->
810810 let width = Scanning.store_char width ib c in
811811- let precision = min width precision in
811811+ let precision = Int.min width precision in
812812 let width = width - (precision - scan_fractional_part precision ib) in
813813 scan_exponent_part width ib, precision
814814 | _ ->
···853853 match Scanning.peek_char ib with
854854 | 'p' | 'P' -> width
855855 | _ ->
856856- let precision = min width precision in
856856+ let precision = Int.min width precision in
857857 width - (precision - scan_hexadecimal_int precision ib)
858858 )
859859 | _ -> width in
···886886 let width = Scanning.store_char width ib c in
887887 (* The effective width available for scanning the fractional part is
888888 the minimum of declared precision and width left. *)
889889- let precision = min width precision in
889889+ let precision = Int.min width precision in
890890 (* After scanning the fractional part with [precision] provisional width,
891891 [width_precision] is left. *)
892892 let width_precision = scan_fractional_part precision ib in
···922922 match Scanning.peek_char ib with
923923 | 'p' | 'P' -> width
924924 | _ ->
925925- let precision = min width precision in
925925+ let precision = Int.min width precision in
926926 width - (precision - scan_hexadecimal_int precision ib)
927927 )
928928 | 'p' | 'P' -> width
+2-2
stdlib/weak.ml
···175175 Array.fold_right (count_bucket 0) t.table 0
176176177177178178- let next_sz n = min (3 * n / 2 + 3) Sys.max_array_length
178178+ let next_sz n = Int.min (3 * n / 2 + 3) Sys.max_array_length
179179 let prev_sz n = ((n - 3) * 2 + 2) / 3
180180181181 let test_shrink_bucket t =
···238238 let rec loop i =
239239 if i >= sz then begin
240240 let newsz =
241241- min (3 * sz / 2 + 3) (Sys.max_array_length - additional_values)
241241+ Int.min (3 * sz / 2 + 3) (Sys.max_array_length - additional_values)
242242 in
243243 if newsz <= sz then failwith "Weak.Make: hash bucket cannot grow more";
244244 let newbucket = weak_create newsz in
+10
testsuite/tests/basic/boxedints.ml
···3737 val div: t -> t -> t
3838 val unsigned_div: t -> t -> t
3939 val rem: t -> t -> t
4040+ val min: t -> t -> t
4141+ val max: t -> t -> t
4042 val logand: t -> t -> t
4143 val logor: t -> t -> t
4244 val logxor: t -> t -> t
···226228 10, 1234567, 12345678;
227229 11, 1234567, -12345678];
228230 test 12 (rem min_int (of_int (-1))) (of_int 0);
231231+232232+ testing_function "min/max";
233233+ test 1 (max (of_int 2) (of_int 3)) (of_int 3);
234234+ test 2 (min (of_int 2) (of_int 3)) (of_int 2);
229235230236 testing_function "and";
231237 List.iter
···486492 10, 1234567, 12345678;
487493 11, 1234567, -12345678];
488494 test 12 (rem min_int (of_int (-1))) (of_int 0);
495495+496496+ testing_function "min/max";
497497+ test 1 (max (of_int 2) (of_int 3)) (of_int 3);
498498+ test 2 (min (of_int 2) (of_int 3)) (of_int 2);
489499490500 testing_function "and";
491501 List.iter
···4343let copy_chars_unix nchars =
4444 let n = ref nchars in
4545 while !n > 0 do
4646- let m = input !inchan copy_buffer 0 (min !n 256) in
4646+ let m = input !inchan copy_buffer 0 (Int.min !n 256) in
4747 if m = 0 then raise End_of_file;
4848 output !outchan copy_buffer 0 m;
4949 n := !n - m
+15-9
typing/ctype.ml
···15981598 (* For gadts, remember type as non exportable *)
15991599 (* The ambiguous level registered for ty' should be the highest *)
16001600 (* if !trace_gadt_instances then begin *)
16011601- let scope = max lv ty.scope in
16011601+ let scope = Int.max lv ty.scope in
16021602 update_scope scope ty;
16031603 update_scope scope ty';
16041604 ty'
···24692469 else if local_non_recursive_abbrev !env source destination then begin
24702470 let destination = duplicate_type destination in
24712471 let expansion_scope =
24722472- max (Path.scope source) (get_gadt_equations_level ())
24722472+ Int.max (Path.scope source) (get_gadt_equations_level ())
24732473 in
24742474 let decl =
24752475 new_local_type ~manifest_and_scope:(destination, expansion_scope) () in
···26972697 ignore (expand_head_unif !env t2);
26982698 let t1' = expand_head_unif !env t1 in
26992699 let t2' = expand_head_unif !env t2 in
27002700- let lv = min t1'.level t2'.level in
27012701- let scope = max t1'.scope t2'.scope in
27002700+ let lv = Int.min t1'.level t2'.level in
27012701+ let scope = Int.max t1'.scope t2'.scope in
27022702 update_level_for Unify !env lv t2;
27032703 update_level_for Unify !env lv t1;
27042704 update_scope_for Unify scope t2;
···29252925 and (fields2, rest2) = flatten_fields ty2 in
29262926 let (pairs, miss1, miss2) = associate_fields fields1 fields2 in
29272927 let l1 = (repr ty1).level and l2 = (repr ty2).level in
29282928- let va = make_rowvar (min l1 l2) (miss2=[]) rest1 (miss1=[]) rest2 in
29282928+ let va = make_rowvar (Int.min l1 l2) (miss2=[]) rest1 (miss1=[]) rest2 in
29292929 let d1 = rest1.desc and d2 = rest2.desc in
29302930 try
29312931 unify env (build_fields l1 miss1 va) rest2;
···29772977 | Some _, Some _ -> if rm2.level < rm1.level then rm2 else rm1
29782978 | Some _, None -> rm1
29792979 | None, Some _ -> rm2
29802980- | None, None -> newty2 (min rm1.level rm2.level) (Tvar None)
29802980+ | None, None -> newty2 (Int.min rm1.level rm2.level) (Tvar None)
29812981 in
29822982 let fixed = merge_fixed_explanation fixed1 fixed2
29832983 and closed = row1.row_closed || row2.row_closed in
···41434143let pred_enlarge n = if n mod 2 = 1 then pred n else n
4144414441454145type change = Unchanged | Equiv | Changed
41464146-let collect l = List.fold_left (fun c1 (_, c2) -> max c1 c2) Unchanged l
41464146+let max_change c1 c2 =
41474147+ match c1, c2 with
41484148+ | _, Changed | Changed, _ -> Changed
41494149+ | Equiv, _ | _, Equiv -> Equiv
41504150+ | _ -> Unchanged
41514151+41524152+let collect l = List.fold_left (fun c1 (_, c2) -> max_change c1 c2) Unchanged l
4147415341484154let rec filter_visited = function
41494155 [] -> []
···41844190 let visited = t :: visited in
41854191 let (t1', c1) = build_subtype env visited loops (not posi) level t1 in
41864192 let (t2', c2) = build_subtype env visited loops posi level t2 in
41874187- let c = max c1 c2 in
41934193+ let c = max_change c1 c2 in
41884194 if c > Unchanged then (newty (Tarrow(l, t1', t2', Cok)), c)
41894195 else (t, Unchanged)
41904196 | Ttuple tlist ->
···43094315 | Tfield(s, _, t1, t2) (* Always present *) ->
43104316 let (t1', c1) = build_subtype env visited loops posi level t1 in
43114317 let (t2', c2) = build_subtype env visited loops posi level t2 in
43124312- let c = max c1 c2 in
43184318+ let c = max_change c1 c2 in
43134319 if c > Unchanged then (newty (Tfield(s, Fpresent, t1', t2')), c)
43144320 else (t, Unchanged)
43154321 | Tnil ->
+1-1
typing/path.ml
···5656let rec scope = function
5757 Pident id -> Ident.scope id
5858 | Pdot(p, _s) -> scope p
5959- | Papply(p1, p2) -> max (scope p1) (scope p2)
5959+ | Papply(p1, p2) -> Int.max (scope p1) (scope p2)
60606161let kfalse _ = false
6262
+1-1
typing/printtyp.ml
···235235let hid_start = 0
236236237237let add_hid_id id map =
238238- let new_id = 1 + Ident.Map.fold (fun _ -> max) map hid_start in
238238+ let new_id = 1 + Ident.Map.fold (fun _ -> Int.max) map hid_start in
239239 new_id, Ident.Map.add id new_id map
240240241241let find_hid id map =
+1-1
utils/binutils.ml
···4646 let max_pos =
4747 match max_len with
4848 | None -> Bytes.length buf
4949- | Some n -> min (Bytes.length buf) (start + n)
4949+ | Some n -> Int.min (Bytes.length buf) (start + n)
5050 in
5151 let rec loop pos =
5252 if pos >= max_pos || Bytes.get buf pos = '\000'
+8-8
utils/misc.ml
···319319 let buff = Bytes.create 0x1000 in
320320 let rec copy n =
321321 if n <= 0 then () else begin
322322- let r = input ic buff 0 (min n 0x1000) in
322322+ let r = input ic buff 0 (Int.min n 0x1000) in
323323 if r = 0 then raise End_of_file else (output oc buff 0 r; copy(n-r))
324324 end
325325 in copy len
···502502 let input_bytes_into tbl ic len =
503503 let count = ref len in
504504 Array.iter (fun str ->
505505- let chunk = min !count (Bytes.length str) in
505505+ let chunk = Int.min !count (Bytes.length str) in
506506 really_input ic str 0 chunk;
507507 count := !count - chunk) tbl
508508···518518 let cutoff =
519519 (* using max_int for cutoff would cause overflows in (i + cutoff + 1);
520520 we bring it back to the (max la lb) worstcase *)
521521- min (max la lb) cutoff in
521521+ Int.min (Int.max la lb) cutoff in
522522 if abs (la - lb) > cutoff then None
523523 else begin
524524 (* initialize with 'cutoff + 1' so that not-yet-written-to cases have
···533533 m.(0).(j) <- j;
534534 done;
535535 for i = 1 to la do
536536- for j = max 1 (i - cutoff - 1) to min lb (i + cutoff + 1) do
536536+ for j = Int.max 1 (i - cutoff - 1) to Int.min lb (i + cutoff + 1) do
537537 let cost = if a.[i-1] = b.[j-1] then 0 else 1 in
538538 let best =
539539 (* insert, delete or substitute *)
540540- min (1 + min m.(i-1).(j) m.(i).(j-1)) (m.(i-1).(j-1) + cost)
540540+ Int.min (1 + Int.min m.(i-1).(j) m.(i).(j-1)) (m.(i-1).(j-1) + cost)
541541 in
542542 let best =
543543 (* swap two adjacent letters; we use "cost" again in case of
···547547 imitation has its virtues *)
548548 if not (i > 1 && j > 1 && a.[i-1] = b.[j-2] && a.[i-2] = b.[j-1])
549549 then best
550550- else min best (m.(i-2).(j-2) + cost)
550550+ else Int.min best (m.(i-2).(j-2) + cost)
551551 in
552552 m.(i).(j) <- best
553553 done;
···779779780780let pp_two_columns ?(sep = "|") ?max_lines ppf (lines: (string * string) list) =
781781 let left_column_size =
782782- List.fold_left (fun acc (s, _) -> max acc (String.length s)) 0 lines in
782782+ List.fold_left (fun acc (s, _) -> Int.max acc (String.length s)) 0 lines in
783783 let lines_nb = List.length lines in
784784 let ellipsed_first, ellipsed_last =
785785 match max_lines with
···10171017 (* a header is "truncated" if it starts like a valid magic number,
10181018 that is if its longest segment of length at most [kind_length]
10191019 is a prefix of [raw_kind kind] for some kind [kind] *)
10201020- let sub_length = min kind_length (String.length s) in
10201020+ let sub_length = Int.min kind_length (String.length s) in
10211021 let starts_as kind =
10221022 String.sub s 0 sub_length = String.sub (raw_kind kind) 0 sub_length
10231023 in
+2-2
utils/profile.ml
···255255let max_by_column ~n_columns rows =
256256 let a = Array.make n_columns 0. in
257257 let rec loop (R (_, values, rows)) =
258258- List.iteri (fun i (v, _) -> a.(i) <- max a.(i) v) values;
258258+ List.iteri (fun i (v, _) -> a.(i) <- Float.max a.(i) v) values;
259259 List.iter loop rows
260260 in
261261 List.iter loop rows;
···266266 let rec loop (R (_, values, rows)) =
267267 List.iteri (fun i cell ->
268268 let _, str = display_cell i cell ~width:0 in
269269- a.(i) <- max a.(i) (String.length str)
269269+ a.(i) <- Int.max a.(i) (String.length str)
270270 ) values;
271271 List.iter loop rows;
272272 in
+2-2
utils/warnings.ml
···556556 let nowhere = { loc_start=pos; loc_end=pos; loc_ghost=true } in
557557 let spelling_hint ppf =
558558 let max_seq_len =
559559- List.fold_left (fun l x -> max l (List.length x))
559559+ List.fold_left (fun l x -> Int.max l (List.length x))
560560 0 consecutive_letters
561561 in
562562 if max_seq_len >= 5 then
···651651 in
652652 List.iter (action modifier) (letter lc)
653653 | Num(n1,n2,modifier) ->
654654- for n = n1 to min n2 last_warning_number do action modifier n done
654654+ for n = n1 to Int.min n2 last_warning_number do action modifier n done
655655 in
656656 let parse_and_eval s =
657657 let tokens = parse_warnings s in