Skip to content

Commit c19b6c5

Browse files
committed
Delimiters is a string now, which is smaller and lets me use find.
1 parent 70bc0e9 commit c19b6c5

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/de/simple_type.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -362,15 +362,15 @@ impl<'de, 'a> SeqAccess<'de> for ListIter<'de, 'a> {
362362
if let Some(mut content) = self.content.take() {
363363
// NOTE: when normalization will be implemented, it may be enough
364364
// to check only b' ', because all whitespaces will be normalized
365-
const DELIMETERS: [u8; 4] = [b' ', b'\t', b'\r', b'\n'];
365+
const DELIMETERS: &str = " \t\r\n";
366366

367367
loop {
368368
let string = content.as_str();
369369
if string.is_empty() {
370370
return Ok(None);
371371
}
372372

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

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

0 commit comments

Comments
 (0)