Simplify parsing a number
This commit is contained in:
parent
fd84aec485
commit
b6371f045f
@ -183,19 +183,8 @@ impl<Iter> Deserializer<Iter>
|
|||||||
// We need to be careful with overflow. If we can, try to keep the
|
// We need to be careful with overflow. If we can, try to keep the
|
||||||
// number as a `u64` until we grow too large. At that point, switch to
|
// number as a `u64` until we grow too large. At that point, switch to
|
||||||
// parsing the value as a `f64`.
|
// parsing the value as a `f64`.
|
||||||
match res.checked_mul(10) {
|
match res.checked_mul(10).and_then(|val| val.checked_add(digit)) {
|
||||||
Some(res_) => {
|
Some(res_) => { res = res_; }
|
||||||
res = res_;
|
|
||||||
match res.checked_add(digit) {
|
|
||||||
Some(res_) => { res = res_; }
|
|
||||||
None => {
|
|
||||||
return self.parse_float(
|
|
||||||
pos,
|
|
||||||
(res as f64) + (digit as f64),
|
|
||||||
visitor);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
None => {
|
None => {
|
||||||
return self.parse_float(
|
return self.parse_float(
|
||||||
pos,
|
pos,
|
||||||
|
Loading…
Reference in New Issue
Block a user