Skip to content

Commit

Permalink
Delimiters is a string now, which is smaller and lets me use find.
Browse files Browse the repository at this point in the history
  • Loading branch information
JGM01 committed Feb 2, 2025
1 parent 70bc0e9 commit c19b6c5
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/de/simple_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -362,15 +362,15 @@ impl<'de, 'a> SeqAccess<'de> for ListIter<'de, 'a> {
if let Some(mut content) = self.content.take() {
// NOTE: when normalization will be implemented, it may be enough
// to check only b' ', because all whitespaces will be normalized
const DELIMETERS: [u8; 4] = [b' ', b'\t', b'\r', b'\n'];
const DELIMETERS: &str = " \t\r\n";

loop {
let string = content.as_str();
if string.is_empty() {
return Ok(None);
}

let first_delimiter = string.as_bytes().iter().position(|c| DELIMETERS.contains(c));
let first_delimiter = string.find(|c| DELIMETERS.contains(c));

return match first_delimiter {
// No delimiters in the `content`, deserialize it as a whole atomic
Expand All @@ -395,7 +395,7 @@ impl<'de, 'a> SeqAccess<'de> for ListIter<'de, 'a> {
// `content` started with a space, skip them all
Some(0) => {
// Skip all spaces
let start = string.as_bytes().iter().position(|c| !DELIMETERS.contains(c));
let start = string.find(|c| !DELIMETERS.contains(c));
content = match (start, content) {
// We cannot find any non-space character, so string contains only spaces
(None, _) => return Ok(None),
Expand Down

0 comments on commit c19b6c5

Please sign in to comment.