diff options
author | Alain Frisch <alain@frisch.fr> | 2014-09-24 09:26:19 +0000 |
---|---|---|
committer | Alain Frisch <alain@frisch.fr> | 2014-09-24 09:26:19 +0000 |
commit | bc3439603a0bf9c6e15de38555fd58cb70251341 (patch) | |
tree | 16bd2e769bd9efa189874632bfe49b106b1e2419 /stdlib/camlinternalFormat.ml | |
parent | f8ca8db7bba2d10291550cacc4047fb11f438d89 (diff) | |
download | ocaml-bc3439603a0bf9c6e15de38555fd58cb70251341.tar.gz |
#6577: fix performance of %C format.
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@15321 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
Diffstat (limited to 'stdlib/camlinternalFormat.ml')
-rw-r--r-- | stdlib/camlinternalFormat.ml | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/stdlib/camlinternalFormat.ml b/stdlib/camlinternalFormat.ml index d3bb7a780e..7fb82dbe29 100644 --- a/stdlib/camlinternalFormat.ml +++ b/stdlib/camlinternalFormat.ml @@ -1344,7 +1344,11 @@ let convert_float fconv prec x = (* Convert a char to a string according to the OCaml lexical convention. *) let format_caml_char c = - String.concat (Char.escaped c) ["'"; "'"] + let str = Char.escaped c in + let l = String.length str in + let res = Bytes.make (l + 2) '\'' in + String.unsafe_blit str 0 res 1 l; + Bytes.unsafe_to_string res (* Convert a format type to string *) let string_of_fmtty fmtty = |