mirror of
https://github.com/c-cube/ocaml-containers.git
synced 2025-12-06 11:15:31 -05:00
perf: use concat_map for CCList.flat_map on >= 5.1
This commit is contained in:
parent
c4dcf1efe2
commit
ad2ceb6e13
1 changed files with 1 additions and 18 deletions
|
|
@ -376,24 +376,7 @@ let[@inline] flat_map f l =
|
||||||
|
|
||||||
[@@@else_]
|
[@@@else_]
|
||||||
|
|
||||||
(* let flat_map = concat_map *)
|
let flat_map = concat_map
|
||||||
let flat_map f l =
|
|
||||||
let rec direct i f l =
|
|
||||||
match l with
|
|
||||||
| [] -> []
|
|
||||||
| [ x ] -> f x
|
|
||||||
| [ x; y ] ->
|
|
||||||
let x = f x in
|
|
||||||
let y = f y in
|
|
||||||
append x y
|
|
||||||
| _ when i = 0 -> flat_map_kont f l Fun.id
|
|
||||||
| x :: y :: tl ->
|
|
||||||
let x = f x in
|
|
||||||
let y = f y in
|
|
||||||
let tl = direct (i - 1) f tl in
|
|
||||||
append x (append y tl)
|
|
||||||
in
|
|
||||||
direct 1000 f l
|
|
||||||
|
|
||||||
[@@@endif]
|
[@@@endif]
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue