Skip to content

Commit

Permalink
sam/io/reader/header: Wrap buffer after selection
Browse files Browse the repository at this point in the history
  • Loading branch information
zaeleus committed Dec 19, 2024
1 parent 5ba0b2b commit 789b35a
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions noodles-sam/src/io/reader/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,17 @@ where

let src = self.inner.fill_buf()?;

if self.is_eol && src.first().map(|&b| b != PREFIX).unwrap_or(true) {
Ok(&[])
let buf = if self.is_eol && src.first().map(|&b| b != PREFIX).unwrap_or(true) {
&[]
} else if let Some(i) = src.as_bstr().find_byte(LINE_FEED) {
self.is_eol = true;
Ok(&src[..=i])
&src[..=i]
} else {
self.is_eol = false;
Ok(src)
}
src
};

Ok(buf)
}

fn consume(&mut self, amt: usize) {
Expand Down

0 comments on commit 789b35a

Please sign in to comment.