CCFormat: List.iter instead of fold_left for append_l (more efficient)

Co-authored-by: Simon Cruanes <simon.cruanes.2007@m4x.org>
This commit is contained in:
Kye W. Shi 2020-12-13 16:24:13 -05:00 committed by Simon Cruanes
parent d0b05fdb76
commit 82781aa9c7

View file

@ -117,7 +117,8 @@ let append ppa ppb fmt () =
"foo" (to_string_test (append (return "foo") (return ""))) "foo" (to_string_test (append (return "foo") (return "")))
*) *)
let append_l = List.fold_left append (return "") let append_l ppl fmt () =
List.iter (fun pp -> pp fmt ()) ppl
(*$= append_l & ~printer:(fun s -> CCFormat.sprintf "%S" s) (*$= append_l & ~printer:(fun s -> CCFormat.sprintf "%S" s)
"" (to_string_test @@ append_l []) "" (to_string_test @@ append_l [])