Skip to content

Commit

Permalink
fix: parsing for f32s with a 48-char representation
Browse files Browse the repository at this point in the history
Signed-off-by: Alex Quick <[email protected]>
  • Loading branch information
alexquick committed Jul 17, 2024
1 parent 152f94a commit b5e5c4c
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions src/utils/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,17 +52,14 @@ where
let c = input[position];
match c {
b'0'..=b'9' | b'a'..=b'z' | b'A'..=b'Z' | b'.' | b'+' | b'-' => {
if token.is_empty() {
token.push(b'$');
}
if token.try_push(c).is_err() {
return Err(ParseVectorError::TooLongNumber { position });
}
}
b',' => {
if !token.is_empty() {
// Safety: all bytes in `token` are ascii characters
let s = unsafe { std::str::from_utf8_unchecked(&token[1..]) };
let s = unsafe { std::str::from_utf8_unchecked(&token) };
let num = f(s).ok_or(ParseVectorError::BadParsing { position })?;
vector.push(num);
token.clear();
Expand All @@ -77,7 +74,7 @@ where
if !token.is_empty() {
let position = right;
// Safety: all bytes in `token` are ascii characters
let s = unsafe { std::str::from_utf8_unchecked(&token[1..]) };
let s = unsafe { std::str::from_utf8_unchecked(&token) };
let num = f(s).ok_or(ParseVectorError::BadParsing { position })?;
vector.push(num);
token.clear();
Expand Down

0 comments on commit b5e5c4c

Please sign in to comment.