Skip to content

Commit

Permalink
revert change, use Jiter solution
Browse files Browse the repository at this point in the history
  • Loading branch information
samuelcolvin committed Jan 17, 2024
1 parent 5ceb41e commit 9479c07
Showing 1 changed file with 18 additions and 12 deletions.
30 changes: 18 additions & 12 deletions src/python.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use pyo3::{ffi, AsPyPointer};
use hashbrown::hash_map::{HashMap, RawEntryMut};
use smallvec::SmallVec;

use crate::errors::{json_err, JsonError, JsonResult, DEFAULT_RECURSION_LIMIT};
use crate::errors::{json_err, json_error, JsonError, JsonResult, DEFAULT_RECURSION_LIMIT};
use crate::number_decoder::{NumberAny, NumberInt};
use crate::parse::{Parser, Peek};
use crate::string_decoder::{StringDecoder, Tape};
Expand Down Expand Up @@ -71,16 +71,6 @@ impl<'j> PythonParser<'j> {
self.parser.consume_false()?;
Ok(false.to_object(py))
}
_ if peek.is_num() => {
let n = self
.parser
.consume_number::<NumberAny>(peek.into_inner(), self.allow_inf_nan)?;
match n {
NumberAny::Int(NumberInt::Int(int)) => Ok(int.to_object(py)),
NumberAny::Int(NumberInt::BigInt(big_int)) => Ok(big_int.to_object(py)),
NumberAny::Float(float) => Ok(float.to_object(py)),
}
}
Peek::String => {
let s = self.parser.consume_string::<StringDecoder>(&mut self.tape)?;
Ok(StringCache::get(py, s.as_str()))
Expand Down Expand Up @@ -127,7 +117,23 @@ impl<'j> PythonParser<'j> {
}
Ok(dict.to_object(py))
}
_ => json_err!(ExpectedSomeValue, self.parser.index),
_ => {
let n = self
.parser
.consume_number::<NumberAny>(peek.into_inner(), self.allow_inf_nan);
match n {
Ok(NumberAny::Int(NumberInt::Int(int))) => Ok(int.to_object(py)),
Ok(NumberAny::Int(NumberInt::BigInt(big_int))) => Ok(big_int.to_object(py)),
Ok(NumberAny::Float(float)) => Ok(float.to_object(py)),
Err(e) => {
if !peek.is_num() {
Err(json_error!(ExpectedSomeValue, self.parser.index))
} else {
Err(e)
}
}
}
}
}
}

Expand Down

0 comments on commit 9479c07

Please sign in to comment.