Simplify parsing a number

This commit is contained in:
Erick Tryzelaar 2015-08-06 07:12:00 -07:00
parent fd84aec485
commit b6371f045f

View File

@ -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,