From dce2dd3301595ddd358275780fb2b502b288fb2b Mon Sep 17 00:00:00 2001 From: Simmo Saan Date: Mon, 18 Jul 2022 18:30:49 +0300 Subject: [PATCH] Remove write_float_fast and write_std_float_fast --- CHANGES.md | 4 ++++ lib/write.ml | 37 ++----------------------------------- lib/write.mli | 2 -- 3 files changed, 6 insertions(+), 37 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 2adaa770..03593f46 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -6,6 +6,10 @@ ### Removed +- Removed undocumented and unused functions `write_float_fast` and + `write_std_float_fast` from `Yojson`, `Yojson.Basic` and `Yojson.Safe` + (@sim642, #149) + ### Changed ### Fixed diff --git a/lib/write.ml b/lib/write.ml index 12a7bb44..40404d91 100644 --- a/lib/write.ml +++ b/lib/write.ml @@ -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 -> @@ -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 -> diff --git a/lib/write.mli b/lib/write.mli index f6d3436c..bf3dd23b 100644 --- a/lib/write.mli +++ b/lib/write.mli @@ -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