The unpac monorepo manager self-hosting as a monorepo using unpac
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Add {Int,Int32,Int64,NativeInt}.{min,max} (#10392)

authored by

Alain Frisch and committed by
GitHub
79f6c222 ea2b1653

+183 -79
+3
Changes
··· 165 165 - #4070, #10398: small optimization of Stdlib.{frexp,modf}. 166 166 (Markus Mottl, Nicolás Ojeda Bär, review by Gabriel Scherer) 167 167 168 + - #10389, #10391, #10392: Add {Int,Int32,Int64,Nativeint}.{min,max}. 169 + (Nicolás Ojeda Bär and Alain Frisch, review by Xavier Leroy) 170 + 168 171 ### Other libraries: 169 172 170 173 - #10047: Add `Unix.realpath`
+1 -1
asmcomp/branch_relaxation.ml
··· 130 130 let rec relax f ~max_out_of_line_code_offset = 131 131 let min_of_max_branch_offsets = 132 132 List.fold_left (fun min_of_max_branch_offsets branch -> 133 - min min_of_max_branch_offsets 133 + Int.min min_of_max_branch_offsets 134 134 (T.Cond_branch.max_displacement branch)) 135 135 max_int T.Cond_branch.all 136 136 in
+1 -1
asmcomp/coloring.ml
··· 77 77 if not (Reg.is_visited r) then begin 78 78 Reg.mark_visited r; 79 79 f r w; 80 - List.iter (fun (r1, w1) -> walk r1 (min w w1)) r.prefer 80 + List.iter (fun (r1, w1) -> walk r1 (Int.min w w1)) r.prefer 81 81 end in 82 82 List.iter (fun (r, w) -> walk r w) reg.prefer; 83 83 Reg.clear_visited_marks () in
+4 -4
asmcomp/emitaux.ml
··· 74 74 end else begin 75 75 let i = ref 0 in 76 76 while !i < l do 77 - let n = min (l - !i) 80 in 77 + let n = Int.min (l - !i) 80 in 78 78 emit_string directive; 79 79 emit_string_literal (String.sub s !i n); 80 80 emit_char '\n'; ··· 248 248 a.efa_string defname 249 249 in 250 250 let pack_info fd_raise d has_next = 251 - let line = min 0xFFFFF d.Debuginfo.dinfo_line 252 - and char_start = min 0xFF d.Debuginfo.dinfo_char_start 253 - and char_end = min 0x3FF d.Debuginfo.dinfo_char_end 251 + let line = Int.min 0xFFFFF d.Debuginfo.dinfo_line 252 + and char_start = Int.min 0xFF d.Debuginfo.dinfo_char_start 253 + and char_end = Int.min 0x3FF d.Debuginfo.dinfo_char_end 254 254 and kind = if fd_raise then 1 else 0 255 255 and has_next = if has_next then 1 else 0 in 256 256 Int64.(add (shift_left (of_int line) 44)
+1 -1
asmcomp/schedgen.ml
··· 121 121 node.length <- 122 122 List.fold_left 123 123 (fun len (son, delay) -> 124 - max len (longest_path critical_outputs son + delay)) 124 + Int.max len (longest_path critical_outputs son + delay)) 125 125 0 sons 126 126 end; 127 127 node.length
+1 -1
asmcomp/selectgen.ml
··· 570 570 self#insert env (Iop Imove) [|src|] [|dst|] 571 571 572 572 method insert_moves env src dst = 573 - for i = 0 to min (Array.length src) (Array.length dst) - 1 do 573 + for i = 0 to Stdlib.Int.min (Array.length src) (Array.length dst) - 1 do 574 574 self#insert_move env src.(i) dst.(i) 575 575 done 576 576
+2 -2
asmcomp/spill.ml
··· 169 169 let date_ifso = !current_date in 170 170 current_date := date_fork; 171 171 let (new_ifnot, after_ifnot) = reload ifnot at_fork in 172 - current_date := max date_ifso !current_date; 172 + current_date := Int.max date_ifso !current_date; 173 173 let (new_next, finally) = 174 174 reload i.next (Reg.Set.union after_ifso after_ifnot) in 175 175 let new_i = ··· 189 189 current_date := date_fork; 190 190 let (new_c, after_c) = reload c at_fork in 191 191 after_cases := Reg.Set.union !after_cases after_c; 192 - date_join := max !date_join !current_date; 192 + date_join := Int.max !date_join !current_date; 193 193 new_c) 194 194 cases in 195 195 current_date := !date_join;
+1 -1
debugger/command_line.ml
··· 799 799 1 800 800 | None -> 801 801 begin try 802 - max 1 (line - 10) 802 + Int.max 1 (line - 10) 803 803 with Out_of_range -> 804 804 1 805 805 end
+2 -2
debugger/time_travel.ml
··· 506 506 let 507 507 {c_time = t} = find_checkpoint_before (pre64 time_max) 508 508 in 509 - go_to (max time t); 509 + go_to (Int64.max time t); 510 510 let (new_time, break) = find_last_breakpoint time_max in 511 511 if break <> None || (new_time <= time) then begin 512 512 go_to new_time; ··· 520 520 let step_backward duration = 521 521 let time = current_time () in 522 522 if time > _0 then 523 - back_to (max _0 (time -- duration)) time 523 + back_to (Int64.max _0 (time -- duration)) time 524 524 525 525 (* Run the program from current time. *) 526 526 (* Stop at the first breakpoint, or at the end of the program. *)
+2 -2
lambda/simplif.ml
··· 113 113 match Hashtbl.find_opt exits i with 114 114 | Some r -> 115 115 r.count <- r.count + nb; 116 - r.max_depth <- max r.max_depth d 116 + r.max_depth <- Int.max r.max_depth d 117 117 | None -> 118 118 let r = {count = nb; max_depth = d} in 119 119 Hashtbl.add exits i r ··· 155 155 increases j's ref count *) 156 156 count ~try_depth l1 ; 157 157 let ic = get_exit i in 158 - incr_exit j ic.count (max try_depth ic.max_depth) 158 + incr_exit j ic.count (Int.max try_depth ic.max_depth) 159 159 | Lstaticcatch(l1, (i,_), l2) -> 160 160 count ~try_depth l1; 161 161 (* If l1 does not contain (exit i),
+1 -1
lex/common.ml
··· 55 55 let copy_chars_unix ic oc start stop = 56 56 let n = ref (stop - start) in 57 57 while !n > 0 do 58 - let m = input ic copy_buffer 0 (min !n 1024) in 58 + let m = input ic copy_buffer 0 (Int.min !n 1024) in 59 59 output oc copy_buffer 0 m; 60 60 n := !n - m 61 61 done
+2 -2
lex/cset.ml
··· 55 55 else if c2' < c1 then 56 56 inter l r' 57 57 else if c2 < c2' then 58 - (max c1 c1', c2)::inter r l' 58 + (Int.max c1 c1', c2)::inter r l' 59 59 else 60 - (max c1 c1', c2')::inter l r' 60 + (Int.max c1 c1', c2')::inter l r' 61 61 62 62 let rec diff l l' = match l, l' with 63 63 _, [] -> l
+1 -1
lex/lexgen.ml
··· 494 494 Alt(reg, Seq(r, Action count)), 495 495 (count, m ,act) :: actions, 496 496 (succ count), 497 - max loc_ntags ntags) 497 + Int.max loc_ntags ntags) 498 498 (Empty, [], 0, 0) 499 499 casedef in 500 500 r
+1 -1
middle_end/flambda/flambda_to_clambda.ml
··· 428 428 List.iter 429 429 (fun (key, lam) -> 430 430 index.(key) <- store.act_store () lam; 431 - smallest_key := min key !smallest_key 431 + smallest_key := Int.min key !smallest_key 432 432 ) 433 433 cases; 434 434 if !smallest_key < num_keys then begin
+2 -2
middle_end/flambda/inline_and_simplify_aux.ml
··· 333 333 try 334 334 Closure_origin.Map.find id t.inlining_counts 335 335 with Not_found -> 336 - max 1 (Clflags.Int_arg_helper.get 336 + Int.max 1 (Clflags.Int_arg_helper.get 337 337 ~key:t.round !Clflags.inline_max_unroll) 338 338 in 339 339 inlining_count > 0 ··· 343 343 try 344 344 Closure_origin.Map.find id t.inlining_counts 345 345 with Not_found -> 346 - max 1 (Clflags.Int_arg_helper.get 346 + Int.max 1 (Clflags.Int_arg_helper.get 347 347 ~key:t.round !Clflags.inline_max_unroll) 348 348 in 349 349 let inlining_counts =
+3 -3
middle_end/flambda/inlining_cost.ml
··· 172 172 | Never_inline, _ -> Never_inline 173 173 | _, Never_inline -> Never_inline 174 174 | Can_inline_if_no_larger_than i1, Can_inline_if_no_larger_than i2 -> 175 - Can_inline_if_no_larger_than (min i1 i2) 175 + Can_inline_if_no_larger_than (Int.min i1 i2) 176 176 177 177 let equal t1 t2 = 178 178 match t1, t2 with ··· 674 674 let inline_call_cost = cost !Clflags.inline_call_cost ~round in 675 675 direct_call_size + (inline_call_cost * benefit_factor) 676 676 in 677 - max_cost := max !max_cost max_size 677 + max_cost := Int.max !max_cost max_size 678 678 done; 679 679 !max_cost 680 680 end ··· 687 687 let inline_prim_cost = cost !Clflags.inline_prim_cost ~round in 688 688 inline_prim_cost * benefit_factor 689 689 in 690 - max_cost := max !max_cost max_size 690 + max_cost := Int.max !max_cost max_size 691 691 done; 692 692 !max_cost 693 693 end
+4 -4
ocamldoc/odoc_dag2html.ml
··· 228 228 next_l next_j; 229 229 flush stderr 230 230 end; 231 - let next_l = min next_l next_j in 231 + let next_l = Int.min next_l next_j in 232 232 let colspan = 3 * (next_l - l) - 2 in 233 233 let les = 234 234 match t.table.(i).(l).elem, t.table.(i + 1).(l).elem with ··· 343 343 match get_block t i (j + 1) with 344 344 Some ((x1, c1) :: list, mpc, span) -> 345 345 let (list, mpc) = 346 - if x1 = x.elem then (x1, c1 + 1) :: list, max mpc (c1 + 1) 347 - else (x.elem, 1) :: (x1, c1) :: list, max mpc c1 346 + if x1 = x.elem then (x1, c1 + 1) :: list, Int.max mpc (c1 + 1) 347 + else (x.elem, 1) :: (x1, c1) :: list, Int.max mpc c1 348 348 in 349 349 Some (list, mpc, span) 350 350 | _ -> assert false ··· 753 753 in 754 754 if nii <> ii || njj1 <> jj1 || njj2 <> jj2 || njj3 <> jj3 || 755 755 njj4 <> jj4 then 756 - let nii = min ii nii in 756 + let nii = Int.min ii nii in 757 757 let (jj1, jj2, jj3, jj4) = 758 758 find_linked_children t nii njj1 njj2 njj3 njj4 759 759 in
+1 -1
ocamltest/ocamltest_stdlib.ml
··· 183 183 let copy_chan ic oc = 184 184 let m = in_channel_length ic in 185 185 let m = (m lsr 12) lsl 12 in 186 - let m = max 16384 (min Sys.max_string_length m) in 186 + let m = Int.max 16384 (Int.min Sys.max_string_length m) in 187 187 let buf = Bytes.create m in 188 188 let rec loop () = 189 189 let len = input ic buf 0 m in
+2 -2
otherlibs/str/str.ml
··· 385 385 emit_instr op_BEGGROUP n; 386 386 emit_code r; 387 387 emit_instr op_ENDGROUP n; 388 - numgroups := max !numgroups (n+1) 388 + numgroups := Int.max !numgroups (n+1) 389 389 | Refgroup n -> 390 390 emit_instr op_REFGROUP n; 391 - numgroups := max !numgroups (n+1) 391 + numgroups := Int.max !numgroups (n+1) 392 392 | Bol -> 393 393 emit_instr op_BOL 0 394 394 | Eol ->
+14
stdlib/.depend
··· 3 3 stdlib__String.cmi \ 4 4 stdlib__Printf.cmi \ 5 5 stdlib__List.cmi \ 6 + stdlib__Int.cmi \ 6 7 stdlib__Buffer.cmi \ 7 8 stdlib__Array.cmi \ 8 9 stdlib__Arg.cmi ··· 11 12 stdlib__String.cmx \ 12 13 stdlib__Printf.cmx \ 13 14 stdlib__List.cmx \ 15 + stdlib__Int.cmx \ 14 16 stdlib__Buffer.cmx \ 15 17 stdlib__Array.cmx \ 16 18 stdlib__Arg.cmi ··· 80 82 stdlib__Sys.cmi \ 81 83 stdlib.cmi \ 82 84 stdlib__Seq.cmi \ 85 + stdlib__Int.cmi \ 83 86 stdlib__Char.cmi \ 84 87 stdlib__Bytes.cmi 85 88 stdlib__Bytes.cmx : bytes.ml \ 86 89 stdlib__Sys.cmx \ 87 90 stdlib.cmx \ 88 91 stdlib__Seq.cmx \ 92 + stdlib__Int.cmx \ 89 93 stdlib__Char.cmx \ 90 94 stdlib__Bytes.cmi 91 95 stdlib__Bytes.cmi : bytes.mli \ ··· 213 217 stdlib__Random.cmi \ 214 218 stdlib__Obj.cmi \ 215 219 stdlib__Lazy.cmi \ 220 + stdlib__Int.cmi \ 216 221 stdlib__Hashtbl.cmi \ 217 222 stdlib__Array.cmi \ 218 223 stdlib__Ephemeron.cmi ··· 222 227 stdlib__Random.cmx \ 223 228 stdlib__Obj.cmx \ 224 229 stdlib__Lazy.cmx \ 230 + stdlib__Int.cmx \ 225 231 stdlib__Hashtbl.cmx \ 226 232 stdlib__Array.cmx \ 227 233 stdlib__Ephemeron.cmi ··· 338 344 stdlib__Random.cmi \ 339 345 stdlib__Obj.cmi \ 340 346 stdlib__Lazy.cmi \ 347 + stdlib__Int.cmi \ 341 348 stdlib__Array.cmi \ 342 349 stdlib__Hashtbl.cmi 343 350 stdlib__Hashtbl.cmx : hashtbl.ml \ ··· 347 354 stdlib__Random.cmx \ 348 355 stdlib__Obj.cmx \ 349 356 stdlib__Lazy.cmx \ 357 + stdlib__Int.cmx \ 350 358 stdlib__Array.cmx \ 351 359 stdlib__Hashtbl.cmi 352 360 stdlib__Hashtbl.cmi : hashtbl.mli \ ··· 387 395 stdlib__Lexing.cmo : lexing.ml \ 388 396 stdlib__Sys.cmi \ 389 397 stdlib__String.cmi \ 398 + stdlib__Int.cmi \ 390 399 stdlib__Bytes.cmi \ 391 400 stdlib__Array.cmi \ 392 401 stdlib__Lexing.cmi 393 402 stdlib__Lexing.cmx : lexing.ml \ 394 403 stdlib__Sys.cmx \ 395 404 stdlib__String.cmx \ 405 + stdlib__Int.cmx \ 396 406 stdlib__Bytes.cmx \ 397 407 stdlib__Array.cmx \ 398 408 stdlib__Lexing.cmi ··· 581 591 stdlib.cmi \ 582 592 stdlib__Printf.cmi \ 583 593 stdlib__List.cmi \ 594 + stdlib__Int.cmi \ 584 595 camlinternalFormatBasics.cmi \ 585 596 camlinternalFormat.cmi \ 586 597 stdlib__Bytes.cmi \ ··· 591 602 stdlib.cmx \ 592 603 stdlib__Printf.cmx \ 593 604 stdlib__List.cmx \ 605 + stdlib__Int.cmx \ 594 606 camlinternalFormatBasics.cmx \ 595 607 camlinternalFormat.cmx \ 596 608 stdlib__Bytes.cmx \ ··· 695 707 stdlib__Weak.cmo : weak.ml \ 696 708 stdlib__Sys.cmi \ 697 709 stdlib__Obj.cmi \ 710 + stdlib__Int.cmi \ 698 711 stdlib__Hashtbl.cmi \ 699 712 stdlib__Array.cmi \ 700 713 stdlib__Weak.cmi 701 714 stdlib__Weak.cmx : weak.ml \ 702 715 stdlib__Sys.cmx \ 703 716 stdlib__Obj.cmx \ 717 + stdlib__Int.cmx \ 704 718 stdlib__Hashtbl.cmx \ 705 719 stdlib__Array.cmx \ 706 720 stdlib__Weak.cmi
+1 -1
stdlib/StdlibModules
··· 36 36 STDLIB_MODULE_BASENAMES=\ 37 37 camlinternalFormatBasics camlinternalAtomic \ 38 38 stdlib pervasives seq option either result bool char uchar \ 39 - sys list bytes string unit marshal obj array float int int32 int64 nativeint \ 39 + sys list int bytes string unit marshal obj array float int32 int64 nativeint \ 40 40 lexing parsing set map stack queue camlinternalLazy lazy stream buffer \ 41 41 camlinternalFormat printf arg atomic \ 42 42 printexc fun gc digest random hashtbl weak \
+4 -4
stdlib/arg.ml
··· 339 339 340 340 let max_arg_len cur (kwd, spec, doc) = 341 341 match spec with 342 - | Symbol _ -> max cur (String.length kwd) 343 - | _ -> max cur (String.length kwd + second_word doc) 342 + | Symbol _ -> Int.max cur (String.length kwd) 343 + | _ -> Int.max cur (String.length kwd + second_word doc) 344 344 345 345 346 346 let replace_leading_tab s = ··· 355 355 ksd 356 356 | (kwd, (Symbol _ as spec), msg) -> 357 357 let cutcol = second_word msg in 358 - let spaces = String.make ((max 0 (len - cutcol)) + 3) ' ' in 358 + let spaces = String.make ((Int.max 0 (len - cutcol)) + 3) ' ' in 359 359 (kwd, spec, "\n" ^ spaces ^ replace_leading_tab msg) 360 360 | (kwd, spec, msg) -> 361 361 let cutcol = second_word msg in ··· 373 373 let align ?(limit=max_int) speclist = 374 374 let completed = add_help speclist in 375 375 let len = List.fold_left max_arg_len 0 completed in 376 - let len = min len limit in 376 + let len = Int.min len limit in 377 377 List.map (add_padding len) completed 378 378 379 379 let trim_cr s =
+2 -2
stdlib/bytes.ml
··· 84 84 let len = length s ++ left ++ right in 85 85 let r = create len in 86 86 let (srcoff, dstoff) = if left < 0 then -left, 0 else 0, left in 87 - let cpylen = min (length s - srcoff) (len - dstoff) in 87 + let cpylen = Int.min (length s - srcoff) (len - dstoff) in 88 88 if cpylen > 0 then unsafe_blit s srcoff r dstoff cpylen; 89 89 r 90 90 ··· 418 418 let buf = ref (make 256 '\000') in 419 419 let resize () = 420 420 (* resize *) 421 - let new_len = min (2 * length !buf) Sys.max_string_length in 421 + let new_len = Int.min (2 * length !buf) Sys.max_string_length in 422 422 if length !buf = new_len then failwith "Bytes.of_seq: cannot grow bytes"; 423 423 let new_buf = make new_len '\000' in 424 424 blit !buf 0 new_buf 0 !n;
+1 -1
stdlib/camlinternalFormat.ml
··· 260 260 let len = Bytes.length buf.bytes in 261 261 let min_len = buf.ind + overhead in 262 262 if min_len > len then ( 263 - let new_len = max (len * 2) min_len in 263 + let new_len = Int.max (len * 2) min_len in 264 264 let new_str = Bytes.create new_len in 265 265 Bytes.blit buf.bytes 0 new_str 0 len; 266 266 buf.bytes <- new_str;
+4 -2
stdlib/ephemeron.ml
··· 345 345 346 346 let stats h = 347 347 let mbl = 348 - Array.fold_left (fun m b -> max m (bucket_length 0 b)) 0 h.data in 348 + Array.fold_left (fun m b -> Int.max m (bucket_length 0 b)) 0 h.data in 349 349 let histo = Array.make (mbl + 1) 0 in 350 350 Array.iter 351 351 (fun b -> ··· 366 366 let stats_alive h = 367 367 let size = ref 0 in 368 368 let mbl = 369 - Array.fold_left (fun m b -> max m (bucket_length_alive 0 b)) 0 h.data in 369 + Array.fold_left 370 + (fun m b -> Int.max m (bucket_length_alive 0 b)) 0 h.data 371 + in 370 372 let histo = Array.make (mbl + 1) 0 in 371 373 Array.iter 372 374 (fun b ->
+2 -2
stdlib/format.ml
··· 270 270 state.pp_is_new_line <- true; 271 271 let indent = state.pp_margin - width + offset in 272 272 (* Don't indent more than pp_max_indent. *) 273 - let real_indent = min state.pp_max_indent indent in 273 + let real_indent = Int.min state.pp_max_indent indent in 274 274 state.pp_current_indent <- real_indent; 275 275 state.pp_space_left <- state.pp_margin - state.pp_current_indent; 276 276 pp_output_indent state state.pp_current_indent; ··· 806 806 (* If possible maintain pp_min_space_left to its actual value, 807 807 if this leads to a too small max_indent, take half of the 808 808 new margin, if it is greater than 1. *) 809 - max (max (state.pp_margin - state.pp_min_space_left) 809 + Int.max (Int.max (state.pp_margin - state.pp_min_space_left) 810 810 (state.pp_margin / 2)) 1 in 811 811 (* Rebuild invariants. *) 812 812 pp_set_max_indent state new_max_indent
+1 -1
stdlib/hashtbl.ml
··· 236 236 237 237 let stats h = 238 238 let mbl = 239 - Array.fold_left (fun m b -> max m (bucket_length 0 b)) 0 h.data in 239 + Array.fold_left (fun m b -> Int.max m (bucket_length 0 b)) 0 h.data in 240 240 let histo = Array.make (mbl + 1) 0 in 241 241 Array.iter 242 242 (fun b ->
+2
stdlib/int.ml
··· 38 38 external shift_right_logical : int -> int -> int = "%lsrint" 39 39 let equal : int -> int -> bool = ( = ) 40 40 let compare : int -> int -> int = Stdlib.compare 41 + let min x y : t = if x <= y then x else y 42 + let max x y : t = if x >= y then x else y 41 43 external to_float : int -> float = "%floatofint" 42 44 external of_float : float -> int = "%intoffloat" 43 45
+10
stdlib/int.mli
··· 108 108 val compare : int -> int -> int 109 109 (** [compare x y] is {!Stdlib.compare}[ x y] but more efficient. *) 110 110 111 + val min : int -> int -> int 112 + (** Return the smaller of the two arguments. 113 + @since 4.13.0 114 + *) 115 + 116 + val max : int -> int -> int 117 + (** Return the greater of the two arguments. 118 + @since 4.13.0 119 + *) 120 + 111 121 (** {1:convert Converting} *) 112 122 113 123 external to_float : int -> float = "%floatofint"
+3
stdlib/int32.ml
··· 86 86 let unsigned_compare n m = 87 87 compare (sub n min_int) (sub m min_int) 88 88 89 + let min x y : t = if x <= y then x else y 90 + let max x y : t = if x >= y then x else y 91 + 89 92 (* Unsigned division from signed division of the same 90 93 bitness. See Warren Jr., Henry S. (2013). Hacker's Delight (2 ed.), Sec 9-3. 91 94 *)
+11
stdlib/int32.mli
··· 215 215 (** The equal function for int32s. 216 216 @since 4.03.0 *) 217 217 218 + val min: t -> t -> t 219 + (** Return the smaller of the two arguments. 220 + @since 4.13.0 221 + *) 222 + 223 + val max: t -> t -> t 224 + (** Return the greater of the two arguments. 225 + @since 4.13.0 226 + *) 227 + 228 + 218 229 (**/**) 219 230 220 231 (** {1 Deprecated functions} *)
+3
stdlib/int64.ml
··· 85 85 let unsigned_compare n m = 86 86 compare (sub n min_int) (sub m min_int) 87 87 88 + let min x y : t = if x <= y then x else y 89 + let max x y : t = if x >= y then x else y 90 + 88 91 (* Unsigned division from signed division of the same 89 92 bitness. See Warren Jr., Henry S. (2013). Hacker's Delight (2 ed.), Sec 9-3. 90 93 *)
+10
stdlib/int64.mli
··· 234 234 (** The equal function for int64s. 235 235 @since 4.03.0 *) 236 236 237 + val min: t -> t -> t 238 + (** Return the smaller of the two arguments. 239 + @since 4.13.0 240 + *) 241 + 242 + val max: t -> t -> t 243 + (** Return the greater of the two arguments. 244 + @since 4.13.0 245 + *) 246 + 237 247 (**/**) 238 248 239 249 (** {1 Deprecated functions} *)
+1 -2
stdlib/lexing.ml
··· 80 80 end; 81 81 result 82 82 83 - 84 83 let lex_refill read_fun aux_buffer lexbuf = 85 84 let read = 86 85 read_fun aux_buffer (Bytes.length aux_buffer) in ··· 109 108 space since n <= String.length aux_buffer <= String.length buffer. 110 109 Watch out for string length overflow, though. *) 111 110 let newlen = 112 - min (2 * Bytes.length lexbuf.lex_buffer) Sys.max_string_length in 111 + Int.min (2 * Bytes.length lexbuf.lex_buffer) Sys.max_string_length in 113 112 if lexbuf.lex_buffer_len - lexbuf.lex_start_pos + n > newlen 114 113 then failwith "Lexing.lex_refill: cannot grow buffer"; 115 114 let newbuf = Bytes.create newlen in
+3
stdlib/nativeint.ml
··· 75 75 let unsigned_compare n m = 76 76 compare (sub n min_int) (sub m min_int) 77 77 78 + let min x y : t = if x <= y then x else y 79 + let max x y : t = if x >= y then x else y 80 + 78 81 (* Unsigned division from signed division of the same 79 82 bitness. See Warren Jr., Henry S. (2013). Hacker's Delight (2 ed.), Sec 9-3. 80 83 *)
+11
stdlib/nativeint.mli
··· 225 225 (** The equal function for native ints. 226 226 @since 4.03.0 *) 227 227 228 + val min: t -> t -> t 229 + (** Return the smaller of the two arguments. 230 + @since 4.13.0 231 + *) 232 + 233 + val max: t -> t -> t 234 + (** Return the greater of the two arguments. 235 + @since 4.13.0 236 + *) 237 + 238 + 228 239 (**/**) 229 240 230 241 (** {1 Deprecated functions} *)
+1 -1
stdlib/random.ml
··· 49 49 s.st.(i) <- i; 50 50 done; 51 51 let accu = ref "x" in 52 - for i = 0 to 54 + max 55 l do 52 + for i = 0 to 54 + Int.max 55 l do 53 53 let j = i mod 55 in 54 54 let k = i mod l in 55 55 accu := combine !accu seed.(k);
+4 -4
stdlib/scanf.ml
··· 808 808 match c with 809 809 | '.' -> 810 810 let width = Scanning.store_char width ib c in 811 - let precision = min width precision in 811 + let precision = Int.min width precision in 812 812 let width = width - (precision - scan_fractional_part precision ib) in 813 813 scan_exponent_part width ib, precision 814 814 | _ -> ··· 853 853 match Scanning.peek_char ib with 854 854 | 'p' | 'P' -> width 855 855 | _ -> 856 - let precision = min width precision in 856 + let precision = Int.min width precision in 857 857 width - (precision - scan_hexadecimal_int precision ib) 858 858 ) 859 859 | _ -> width in ··· 886 886 let width = Scanning.store_char width ib c in 887 887 (* The effective width available for scanning the fractional part is 888 888 the minimum of declared precision and width left. *) 889 - let precision = min width precision in 889 + let precision = Int.min width precision in 890 890 (* After scanning the fractional part with [precision] provisional width, 891 891 [width_precision] is left. *) 892 892 let width_precision = scan_fractional_part precision ib in ··· 922 922 match Scanning.peek_char ib with 923 923 | 'p' | 'P' -> width 924 924 | _ -> 925 - let precision = min width precision in 925 + let precision = Int.min width precision in 926 926 width - (precision - scan_hexadecimal_int precision ib) 927 927 ) 928 928 | 'p' | 'P' -> width
+2 -2
stdlib/weak.ml
··· 175 175 Array.fold_right (count_bucket 0) t.table 0 176 176 177 177 178 - let next_sz n = min (3 * n / 2 + 3) Sys.max_array_length 178 + let next_sz n = Int.min (3 * n / 2 + 3) Sys.max_array_length 179 179 let prev_sz n = ((n - 3) * 2 + 2) / 3 180 180 181 181 let test_shrink_bucket t = ··· 238 238 let rec loop i = 239 239 if i >= sz then begin 240 240 let newsz = 241 - min (3 * sz / 2 + 3) (Sys.max_array_length - additional_values) 241 + Int.min (3 * sz / 2 + 3) (Sys.max_array_length - additional_values) 242 242 in 243 243 if newsz <= sz then failwith "Weak.Make: hash bucket cannot grow more"; 244 244 let newbucket = weak_create newsz in
+10
testsuite/tests/basic/boxedints.ml
··· 37 37 val div: t -> t -> t 38 38 val unsigned_div: t -> t -> t 39 39 val rem: t -> t -> t 40 + val min: t -> t -> t 41 + val max: t -> t -> t 40 42 val logand: t -> t -> t 41 43 val logor: t -> t -> t 42 44 val logxor: t -> t -> t ··· 226 228 10, 1234567, 12345678; 227 229 11, 1234567, -12345678]; 228 230 test 12 (rem min_int (of_int (-1))) (of_int 0); 231 + 232 + testing_function "min/max"; 233 + test 1 (max (of_int 2) (of_int 3)) (of_int 3); 234 + test 2 (min (of_int 2) (of_int 3)) (of_int 2); 229 235 230 236 testing_function "and"; 231 237 List.iter ··· 486 492 10, 1234567, 12345678; 487 493 11, 1234567, -12345678]; 488 494 test 12 (rem min_int (of_int (-1))) (of_int 0); 495 + 496 + testing_function "min/max"; 497 + test 1 (max (of_int 2) (of_int 3)) (of_int 3); 498 + test 2 (min (of_int 2) (of_int 3)) (of_int 2); 489 499 490 500 testing_function "and"; 491 501 List.iter
+6
testsuite/tests/basic/boxedints.reference
··· 23 23 1... 2... 3... 4... 5... 6... 7... 8... 9... 10... 11... 24 24 mod 25 25 1... 2... 3... 4... 5... 6... 7... 8... 9... 10... 11... 12... 26 + min/max 27 + 1... 2... 26 28 and 27 29 1... 2... 3... 4... 5... 28 30 or ··· 66 68 1... 2... 3... 4... 5... 6... 7... 8... 9... 10... 11... 67 69 mod 68 70 1... 2... 3... 4... 5... 6... 7... 8... 9... 10... 11... 12... 71 + min/max 72 + 1... 2... 69 73 and 70 74 1... 2... 3... 4... 5... 71 75 or ··· 105 109 1... 2... 3... 4... 5... 6... 7... 8... 9... 10... 11... 106 110 mod 107 111 1... 2... 3... 4... 5... 6... 7... 8... 9... 10... 11... 12... 112 + min/max 113 + 1... 2... 108 114 and 109 115 1... 2... 3... 4... 5... 110 116 or
+6
testsuite/tests/lib-int/test.ml
··· 57 57 assert (Int.of_string "" = None); *) 58 58 () 59 59 60 + let test_min_max () = 61 + assert (Int.max 2 3 = 3); 62 + assert (Int.min 2 3 = 2) 63 + 64 + 60 65 let tests () = 61 66 test_consts (); 62 67 test_arith (); ··· 65 70 test_compare (); 66 71 test_float_conv (); 67 72 test_string_conv (); 73 + test_min_max (); 68 74 () 69 75 70 76 let () =
+5
testsuite/tests/lib-int64/test.ml
··· 56 56 assert (Int64.of_string "" = None); *) 57 57 () 58 58 59 + let test_min_max () = 60 + assert (Int64.max 2L 3L = 3L); 61 + assert (Int64.min 2L 3L = 2L) 62 + 59 63 let tests () = 60 64 test_consts (); 61 65 test_arith (); ··· 64 68 test_compare (); 65 69 test_float_conv (); 66 70 test_string_conv (); 71 + test_min_max (); 67 72 () 68 73 69 74 let () =
+1 -1
tools/ocamlprof.ml
··· 43 43 let copy_chars_unix nchars = 44 44 let n = ref nchars in 45 45 while !n > 0 do 46 - let m = input !inchan copy_buffer 0 (min !n 256) in 46 + let m = input !inchan copy_buffer 0 (Int.min !n 256) in 47 47 if m = 0 then raise End_of_file; 48 48 output !outchan copy_buffer 0 m; 49 49 n := !n - m
+15 -9
typing/ctype.ml
··· 1598 1598 (* For gadts, remember type as non exportable *) 1599 1599 (* The ambiguous level registered for ty' should be the highest *) 1600 1600 (* if !trace_gadt_instances then begin *) 1601 - let scope = max lv ty.scope in 1601 + let scope = Int.max lv ty.scope in 1602 1602 update_scope scope ty; 1603 1603 update_scope scope ty'; 1604 1604 ty' ··· 2469 2469 else if local_non_recursive_abbrev !env source destination then begin 2470 2470 let destination = duplicate_type destination in 2471 2471 let expansion_scope = 2472 - max (Path.scope source) (get_gadt_equations_level ()) 2472 + Int.max (Path.scope source) (get_gadt_equations_level ()) 2473 2473 in 2474 2474 let decl = 2475 2475 new_local_type ~manifest_and_scope:(destination, expansion_scope) () in ··· 2697 2697 ignore (expand_head_unif !env t2); 2698 2698 let t1' = expand_head_unif !env t1 in 2699 2699 let t2' = expand_head_unif !env t2 in 2700 - let lv = min t1'.level t2'.level in 2701 - let scope = max t1'.scope t2'.scope in 2700 + let lv = Int.min t1'.level t2'.level in 2701 + let scope = Int.max t1'.scope t2'.scope in 2702 2702 update_level_for Unify !env lv t2; 2703 2703 update_level_for Unify !env lv t1; 2704 2704 update_scope_for Unify scope t2; ··· 2925 2925 and (fields2, rest2) = flatten_fields ty2 in 2926 2926 let (pairs, miss1, miss2) = associate_fields fields1 fields2 in 2927 2927 let l1 = (repr ty1).level and l2 = (repr ty2).level in 2928 - let va = make_rowvar (min l1 l2) (miss2=[]) rest1 (miss1=[]) rest2 in 2928 + let va = make_rowvar (Int.min l1 l2) (miss2=[]) rest1 (miss1=[]) rest2 in 2929 2929 let d1 = rest1.desc and d2 = rest2.desc in 2930 2930 try 2931 2931 unify env (build_fields l1 miss1 va) rest2; ··· 2977 2977 | Some _, Some _ -> if rm2.level < rm1.level then rm2 else rm1 2978 2978 | Some _, None -> rm1 2979 2979 | None, Some _ -> rm2 2980 - | None, None -> newty2 (min rm1.level rm2.level) (Tvar None) 2980 + | None, None -> newty2 (Int.min rm1.level rm2.level) (Tvar None) 2981 2981 in 2982 2982 let fixed = merge_fixed_explanation fixed1 fixed2 2983 2983 and closed = row1.row_closed || row2.row_closed in ··· 4143 4143 let pred_enlarge n = if n mod 2 = 1 then pred n else n 4144 4144 4145 4145 type change = Unchanged | Equiv | Changed 4146 - let collect l = List.fold_left (fun c1 (_, c2) -> max c1 c2) Unchanged l 4146 + let max_change c1 c2 = 4147 + match c1, c2 with 4148 + | _, Changed | Changed, _ -> Changed 4149 + | Equiv, _ | _, Equiv -> Equiv 4150 + | _ -> Unchanged 4151 + 4152 + let collect l = List.fold_left (fun c1 (_, c2) -> max_change c1 c2) Unchanged l 4147 4153 4148 4154 let rec filter_visited = function 4149 4155 [] -> [] ··· 4184 4190 let visited = t :: visited in 4185 4191 let (t1', c1) = build_subtype env visited loops (not posi) level t1 in 4186 4192 let (t2', c2) = build_subtype env visited loops posi level t2 in 4187 - let c = max c1 c2 in 4193 + let c = max_change c1 c2 in 4188 4194 if c > Unchanged then (newty (Tarrow(l, t1', t2', Cok)), c) 4189 4195 else (t, Unchanged) 4190 4196 | Ttuple tlist -> ··· 4309 4315 | Tfield(s, _, t1, t2) (* Always present *) -> 4310 4316 let (t1', c1) = build_subtype env visited loops posi level t1 in 4311 4317 let (t2', c2) = build_subtype env visited loops posi level t2 in 4312 - let c = max c1 c2 in 4318 + let c = max_change c1 c2 in 4313 4319 if c > Unchanged then (newty (Tfield(s, Fpresent, t1', t2')), c) 4314 4320 else (t, Unchanged) 4315 4321 | Tnil ->
+1 -1
typing/path.ml
··· 56 56 let rec scope = function 57 57 Pident id -> Ident.scope id 58 58 | Pdot(p, _s) -> scope p 59 - | Papply(p1, p2) -> max (scope p1) (scope p2) 59 + | Papply(p1, p2) -> Int.max (scope p1) (scope p2) 60 60 61 61 let kfalse _ = false 62 62
+1 -1
typing/printtyp.ml
··· 235 235 let hid_start = 0 236 236 237 237 let add_hid_id id map = 238 - let new_id = 1 + Ident.Map.fold (fun _ -> max) map hid_start in 238 + let new_id = 1 + Ident.Map.fold (fun _ -> Int.max) map hid_start in 239 239 new_id, Ident.Map.add id new_id map 240 240 241 241 let find_hid id map =
+1 -1
utils/binutils.ml
··· 46 46 let max_pos = 47 47 match max_len with 48 48 | None -> Bytes.length buf 49 - | Some n -> min (Bytes.length buf) (start + n) 49 + | Some n -> Int.min (Bytes.length buf) (start + n) 50 50 in 51 51 let rec loop pos = 52 52 if pos >= max_pos || Bytes.get buf pos = '\000'
+8 -8
utils/misc.ml
··· 319 319 let buff = Bytes.create 0x1000 in 320 320 let rec copy n = 321 321 if n <= 0 then () else begin 322 - let r = input ic buff 0 (min n 0x1000) in 322 + let r = input ic buff 0 (Int.min n 0x1000) in 323 323 if r = 0 then raise End_of_file else (output oc buff 0 r; copy(n-r)) 324 324 end 325 325 in copy len ··· 502 502 let input_bytes_into tbl ic len = 503 503 let count = ref len in 504 504 Array.iter (fun str -> 505 - let chunk = min !count (Bytes.length str) in 505 + let chunk = Int.min !count (Bytes.length str) in 506 506 really_input ic str 0 chunk; 507 507 count := !count - chunk) tbl 508 508 ··· 518 518 let cutoff = 519 519 (* using max_int for cutoff would cause overflows in (i + cutoff + 1); 520 520 we bring it back to the (max la lb) worstcase *) 521 - min (max la lb) cutoff in 521 + Int.min (Int.max la lb) cutoff in 522 522 if abs (la - lb) > cutoff then None 523 523 else begin 524 524 (* initialize with 'cutoff + 1' so that not-yet-written-to cases have ··· 533 533 m.(0).(j) <- j; 534 534 done; 535 535 for i = 1 to la do 536 - for j = max 1 (i - cutoff - 1) to min lb (i + cutoff + 1) do 536 + for j = Int.max 1 (i - cutoff - 1) to Int.min lb (i + cutoff + 1) do 537 537 let cost = if a.[i-1] = b.[j-1] then 0 else 1 in 538 538 let best = 539 539 (* insert, delete or substitute *) 540 - min (1 + min m.(i-1).(j) m.(i).(j-1)) (m.(i-1).(j-1) + cost) 540 + Int.min (1 + Int.min m.(i-1).(j) m.(i).(j-1)) (m.(i-1).(j-1) + cost) 541 541 in 542 542 let best = 543 543 (* swap two adjacent letters; we use "cost" again in case of ··· 547 547 imitation has its virtues *) 548 548 if not (i > 1 && j > 1 && a.[i-1] = b.[j-2] && a.[i-2] = b.[j-1]) 549 549 then best 550 - else min best (m.(i-2).(j-2) + cost) 550 + else Int.min best (m.(i-2).(j-2) + cost) 551 551 in 552 552 m.(i).(j) <- best 553 553 done; ··· 779 779 780 780 let pp_two_columns ?(sep = "|") ?max_lines ppf (lines: (string * string) list) = 781 781 let left_column_size = 782 - List.fold_left (fun acc (s, _) -> max acc (String.length s)) 0 lines in 782 + List.fold_left (fun acc (s, _) -> Int.max acc (String.length s)) 0 lines in 783 783 let lines_nb = List.length lines in 784 784 let ellipsed_first, ellipsed_last = 785 785 match max_lines with ··· 1017 1017 (* a header is "truncated" if it starts like a valid magic number, 1018 1018 that is if its longest segment of length at most [kind_length] 1019 1019 is a prefix of [raw_kind kind] for some kind [kind] *) 1020 - let sub_length = min kind_length (String.length s) in 1020 + let sub_length = Int.min kind_length (String.length s) in 1021 1021 let starts_as kind = 1022 1022 String.sub s 0 sub_length = String.sub (raw_kind kind) 0 sub_length 1023 1023 in
+2 -2
utils/profile.ml
··· 255 255 let max_by_column ~n_columns rows = 256 256 let a = Array.make n_columns 0. in 257 257 let rec loop (R (_, values, rows)) = 258 - List.iteri (fun i (v, _) -> a.(i) <- max a.(i) v) values; 258 + List.iteri (fun i (v, _) -> a.(i) <- Float.max a.(i) v) values; 259 259 List.iter loop rows 260 260 in 261 261 List.iter loop rows; ··· 266 266 let rec loop (R (_, values, rows)) = 267 267 List.iteri (fun i cell -> 268 268 let _, str = display_cell i cell ~width:0 in 269 - a.(i) <- max a.(i) (String.length str) 269 + a.(i) <- Int.max a.(i) (String.length str) 270 270 ) values; 271 271 List.iter loop rows; 272 272 in
+2 -2
utils/warnings.ml
··· 556 556 let nowhere = { loc_start=pos; loc_end=pos; loc_ghost=true } in 557 557 let spelling_hint ppf = 558 558 let max_seq_len = 559 - List.fold_left (fun l x -> max l (List.length x)) 559 + List.fold_left (fun l x -> Int.max l (List.length x)) 560 560 0 consecutive_letters 561 561 in 562 562 if max_seq_len >= 5 then ··· 651 651 in 652 652 List.iter (action modifier) (letter lc) 653 653 | Num(n1,n2,modifier) -> 654 - for n = n1 to min n2 last_warning_number do action modifier n done 654 + for n = n1 to Int.min n2 last_warning_number do action modifier n done 655 655 in 656 656 let parse_and_eval s = 657 657 let tokens = parse_warnings s in