Skip to content

Commit add85c7

Browse files
committed
Move efficient concat to stdlib
Signed-off-by: Rudi Grinberg <rudi.grinberg@gmail.com>
1 parent babaea1 commit add85c7

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

src/action.ml

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -280,11 +280,6 @@ let prog_and_args_of_values p ~dir =
280280

281281
module SW = String_with_vars
282282

283-
let concat = function
284-
| [] -> ""
285-
| [x] -> x
286-
| xs -> String.concat ~sep:"" xs
287-
288283
module Unexpanded = struct
289284
module type Uast = Action_intf.Ast
290285
with type program = String_with_vars.t
@@ -693,7 +688,7 @@ let rec exec t ~ectx ~dir ~env ~stdout_to ~stderr_to =
693688
exec t ~ectx ~dir ~stdout_to ~stderr_to
694689
~env:(Env.add env ~var ~value)
695690
| Redirect (Stdout, fn, Echo s) ->
696-
Io.write_file fn (concat s);
691+
Io.write_file fn (String.concat s ~sep:"");
697692
Fiber.return ()
698693
| Redirect (outputs, fn, Run (Ok prog, args)) ->
699694
let out = Process.File fn in
@@ -710,7 +705,7 @@ let rec exec t ~ectx ~dir ~env ~stdout_to ~stderr_to =
710705
redirect ~ectx ~dir outputs Config.dev_null t ~env ~stdout_to ~stderr_to
711706
| Progn l ->
712707
exec_list l ~ectx ~dir ~env ~stdout_to ~stderr_to
713-
| Echo strs -> exec_echo stdout_to (concat strs)
708+
| Echo strs -> exec_echo stdout_to (String.concat strs ~sep:"")
714709
| Cat fn ->
715710
Io.with_file_in fn ~f:(fun ic ->
716711
let oc =

src/stdune/string.ml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,3 +214,8 @@ let enumerate_gen s =
214214

215215
let enumerate_and = enumerate_gen "and"
216216
let enumerate_or = enumerate_gen "or"
217+
218+
let concat ~sep = function
219+
| [] -> ""
220+
| [x] -> x
221+
| xs -> concat ~sep xs

0 commit comments

Comments
 (0)