From ad2ceb6e137b96a7aac20069443c2f90654ba04c Mon Sep 17 00:00:00 2001 From: Simon Cruanes Date: Fri, 15 Dec 2023 22:37:35 -0500 Subject: [PATCH] perf: use `concat_map` for `CCList.flat_map` on >= 5.1 --- src/core/CCList.ml | 19 +------------------ 1 file changed, 1 insertion(+), 18 deletions(-) diff --git a/src/core/CCList.ml b/src/core/CCList.ml index 2132b313..90d06a26 100644 --- a/src/core/CCList.ml +++ b/src/core/CCList.ml @@ -376,24 +376,7 @@ let[@inline] flat_map f l = [@@@else_] -(* 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 +let flat_map = concat_map [@@@endif]