Skip to content

Commit cc14b52

Browse files
Merge pull request #149 from sim642/rm-write_float_fast
Remove `write_float_fast` and `write_std_float_fast`
2 parents c4c5617 + dce2dd3 commit cc14b52

File tree

3 files changed

+6
-37
lines changed

3 files changed

+6
-37
lines changed

CHANGES.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66

77
### Removed
88

9+
- Removed undocumented and unused functions `write_float_fast` and
10+
`write_std_float_fast` from `Yojson`, `Yojson.Basic` and `Yojson.Safe`
11+
(@sim642, #149)
12+
913
### Changed
1014

1115
### Fixed

lib/write.ml

Lines changed: 2 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -115,25 +115,9 @@ let float_needs_period s =
115115
false
116116

117117
(*
118-
Both write_float_fast and write_float guarantee
119-
that a sufficient number of digits are printed in order to
120-
allow reversibility.
121-
122-
The _fast version is faster but often produces unnecessarily long numbers.
118+
Guarantees that a sufficient number of digits are printed in order to allow
119+
reversibility.
123120
*)
124-
(* unused *)
125-
let write_float_fast ob x =
126-
match classify_float x with
127-
FP_nan ->
128-
Buffer.add_string ob "NaN"
129-
| FP_infinite ->
130-
Buffer.add_string ob (if x > 0. then "Infinity" else "-Infinity")
131-
| _ ->
132-
let s = Printf.sprintf "%.17g" x in
133-
Buffer.add_string ob s;
134-
if float_needs_period s then
135-
Buffer.add_string ob ".0"
136-
137121
let write_float ob x =
138122
match classify_float x with
139123
FP_nan ->
@@ -192,23 +176,6 @@ let json_string_of_float x =
192176
Buffer.contents ob
193177

194178

195-
(* unused *)
196-
let write_std_float_fast ob x =
197-
match classify_float x with
198-
FP_nan ->
199-
json_error "NaN value not allowed in standard JSON"
200-
| FP_infinite ->
201-
json_error
202-
(if x > 0. then
203-
"Infinity value not allowed in standard JSON"
204-
else
205-
"-Infinity value not allowed in standard JSON")
206-
| _ ->
207-
let s = Printf.sprintf "%.17g" x in
208-
Buffer.add_string ob s;
209-
if float_needs_period s then
210-
Buffer.add_string ob ".0"
211-
212179
let write_std_float ob x =
213180
match classify_float x with
214181
FP_nan ->

lib/write.mli

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,6 @@ val write_int : Buffer.t -> int -> unit
124124
#ifdef FLOAT
125125
val write_float : Buffer.t -> float -> unit
126126
val write_std_float : Buffer.t -> float -> unit
127-
val write_float_fast : Buffer.t -> float -> unit
128-
val write_std_float_fast : Buffer.t -> float -> unit
129127
val write_float_prec : int -> Buffer.t -> float -> unit
130128
val write_std_float_prec : int -> Buffer.t -> float -> unit
131129
#endif

0 commit comments

Comments
 (0)