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 GitHub
parent 5466b766d8
commit 657e60ca79
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

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 [])