Skip to content

Commit

Permalink
Remove write_float_fast and write_std_float_fast
Browse files Browse the repository at this point in the history
  • Loading branch information
sim642 committed Jul 18, 2022
1 parent 6aaecec commit 1d7d08f
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 37 deletions.
37 changes: 2 additions & 35 deletions lib/write.ml
Original file line number Diff line number Diff line change
Expand Up @@ -115,25 +115,9 @@ let float_needs_period s =
false

(*
Both write_float_fast and write_float guarantee
that a sufficient number of digits are printed in order to
allow reversibility.
The _fast version is faster but often produces unnecessarily long numbers.
Guarantees that a sufficient number of digits are printed in order to allow
reversibility.
*)
(* unused *)
let write_float_fast ob x =
match classify_float x with
FP_nan ->
Buffer.add_string ob "NaN"
| FP_infinite ->
Buffer.add_string ob (if x > 0. then "Infinity" else "-Infinity")
| _ ->
let s = Printf.sprintf "%.17g" x in
Buffer.add_string ob s;
if float_needs_period s then
Buffer.add_string ob ".0"

let write_float ob x =
match classify_float x with
FP_nan ->
Expand Down Expand Up @@ -192,23 +176,6 @@ let json_string_of_float x =
Buffer.contents ob


(* unused *)
let write_std_float_fast ob x =
match classify_float x with
FP_nan ->
json_error "NaN value not allowed in standard JSON"
| FP_infinite ->
json_error
(if x > 0. then
"Infinity value not allowed in standard JSON"
else
"-Infinity value not allowed in standard JSON")
| _ ->
let s = Printf.sprintf "%.17g" x in
Buffer.add_string ob s;
if float_needs_period s then
Buffer.add_string ob ".0"

let write_std_float ob x =
match classify_float x with
FP_nan ->
Expand Down
2 changes: 0 additions & 2 deletions lib/write.mli
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,6 @@ val write_int : Buffer.t -> int -> unit
#ifdef FLOAT
val write_float : Buffer.t -> float -> unit
val write_std_float : Buffer.t -> float -> unit
val write_float_fast : Buffer.t -> float -> unit
val write_std_float_fast : Buffer.t -> float -> unit
val write_float_prec : int -> Buffer.t -> float -> unit
val write_std_float_prec : int -> Buffer.t -> float -> unit
#endif
Expand Down

0 comments on commit 1d7d08f

Please sign in to comment.