perf: a few more inline annotations

This commit is contained in:
Simon Cruanes 2020-05-12 12:46:12 -04:00
parent 97e49b6a5c
commit 18222af1a3
2 changed files with 10 additions and 10 deletions

View file

@ -474,7 +474,7 @@ let count_true_false p l =
count_true_false (fun x -> x mod 2 = 0) [2; 6; 9; 4] = (3, 1) count_true_false (fun x -> x mod 2 = 0) [2; 6; 9; 4] = (3, 1)
*) *)
let product f l1 l2 = let[@inline] product f l1 l2 =
flat_map (fun x -> map (fun y -> f x y) l2) l1 flat_map (fun x -> map (fun y -> f x y) l2) l1
let fold_product f acc l1 l2 = let fold_product f acc l1 l2 =
@ -1789,8 +1789,8 @@ let of_klist l =
direct direct_depth_default_ l direct direct_depth_default_ l
module Infix = struct module Infix = struct
let (>|=) l f = map f l let[@inline] (>|=) l f = map f l
let (>>=) l f = flat_map f l let[@inline] (>>=) l f = flat_map f l
let (@) = (@) let (@) = (@)
let (<*>) = (<*>) let (<*>) = (<*>)
let (<$>) = map let (<$>) = map
@ -1801,7 +1801,7 @@ module Infix = struct
type 'a t = 'a list type 'a t = 'a list
let (>|=) = (>|=) let (>|=) = (>|=)
let (>>=) = (>>=) let (>>=) = (>>=)
let monoid_product l1 l2 = product (fun x y -> x,y) l1 l2 let[@inline] monoid_product l1 l2 = product (fun x y -> x,y) l1 l2
end) end)
end end

View file

@ -4,7 +4,7 @@
type 'a t = 'a option type 'a t = 'a option
let map f = function let[@inline] map f = function
| None -> None | None -> None
| Some x -> Some (f x) | Some x -> Some (f x)
@ -38,11 +38,11 @@ let equal f o1 o2 = match o1, o2 with
let return x = Some x let return x = Some x
let flat_map f o = match o with let[@inline] flat_map f o = match o with
| None -> None | None -> None
| Some x -> f x | Some x -> f x
let bind o f = flat_map f o let[@inline] bind o f = flat_map f o
let (>>=) = bind let (>>=) = bind
@ -169,7 +169,7 @@ module Infix = struct
type 'a t = 'a option type 'a t = 'a option
let (>|=) = (>|=) let (>|=) = (>|=)
let (>>=) = (>>=) let (>>=) = (>>=)
let monoid_product o1 o2 = match o1, o2 with let[@inline] monoid_product o1 o2 = match o1, o2 with
| Some x, Some y -> Some (x,y) | Some x, Some y -> Some (x,y)
| _ -> None | _ -> None
end) end)