feat(parser): improve inline object parsing
This commit is contained in:
parent
c4041aefb6
commit
3beabcedfa
3 changed files with 98 additions and 76 deletions
|
|
@ -2,7 +2,6 @@ use bytecount::count;
|
|||
use memchr::memchr;
|
||||
|
||||
#[inline]
|
||||
/// returns offset
|
||||
pub fn parse(text: &str, marker: u8) -> Option<usize> {
|
||||
debug_assert!(text.len() >= 3);
|
||||
|
||||
|
|
@ -12,7 +11,7 @@ pub fn parse(text: &str, marker: u8) -> Option<usize> {
|
|||
return None;
|
||||
}
|
||||
|
||||
let end = memchr(marker, &bytes[1..]).filter(|&i| count(&bytes[1..i + 1], b'\n') < 2)?;
|
||||
let end = memchr(marker, &bytes[1..]).filter(|&i| count(&bytes[1..=i], b'\n') < 2)?;
|
||||
|
||||
if bytes[end].is_ascii_whitespace() {
|
||||
return None;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue