From ccd2a92ba56657e7aa165dec30ef847cadbe47aa Mon Sep 17 00:00:00 2001 From: Josh Berdine Date: Wed, 29 May 2019 09:06:13 -0700 Subject: [PATCH] [sledge] Avoid Format in non-debug code Summary: Format is slow. Especially Format.sprintf, which has to allocate and initialize a buffer every time. Reviewed By: kren1 Differential Revision: D15535437 fbshipit-source-id: ea43f44e1 --- sledge/src/llair/frontend.ml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sledge/src/llair/frontend.ml b/sledge/src/llair/frontend.ml index 504afb90e..76bcf3e2c 100644 --- a/sledge/src/llair/frontend.ml +++ b/sledge/src/llair/frontend.ml @@ -97,10 +97,10 @@ let ( (scan_names_and_locs : Llvm.llmodule -> unit) match Hashtbl.find void_tbl fname with | None -> Hashtbl.set void_tbl ~key:fname ~data:1 ; - Format.sprintf "%s.void" fname + fname ^ ".void" | Some count -> Hashtbl.set void_tbl ~key:fname ~data:(count + 1) ; - Format.sprintf "%s.void.%i" fname count ) + String.concat_array [|fname; ".void."; Int.to_string count|] ) | _ -> ( match Llvm.value_name llv with | "" -> @@ -112,7 +112,7 @@ let ( (scan_names_and_locs : Llvm.llmodule -> unit) match Int.of_string name with | _ -> (* escape to avoid clash with names of anonymous values *) - Format.sprintf "\"%s\"" name + String.concat_array [|"\""; name; "\""|] | exception _ -> name ) ) in Hashtbl.add_exn name_tbl ~key:llv ~data:name