Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions src/de/simple_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ use crate::encoding::Decoder;
use crate::errors::serialize::DeError;
use crate::escape::unescape;
use crate::utils::CowRef;
use memchr::memchr;
use serde::de::value::UnitDeserializer;
use serde::de::{
DeserializeSeed, Deserializer, EnumAccess, IntoDeserializer, SeqAccess, VariantAccess, Visitor,
Expand Down Expand Up @@ -361,14 +360,17 @@ impl<'de, 'a> SeqAccess<'de> for ListIter<'de, 'a> {
T: DeserializeSeed<'de>,
{
if let Some(mut content) = self.content.take() {
const DELIMITER: u8 = b' ';
const DELIMETERS: [u8; 4] = [b' ', b'\t', b'\r', b'\n'];

loop {
let string = content.as_str();
if string.is_empty() {
return Ok(None);
}
return match memchr(DELIMITER, string.as_bytes()) {

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

return match first_delimiter {
// No delimiters in the `content`, deserialize it as a whole atomic
None => match content {
Content::Input(s) => seed.deserialize(AtomicDeserializer {
Expand All @@ -391,7 +393,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(|ch| *ch != DELIMITER);
let start = string.as_bytes().iter().position(|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
Loading