swf: Extract `BitReader::new`

This commit is contained in:
relrelb 2021-10-02 18:55:06 +03:00 committed by Mike Welsh
parent 4ad6e1e698
commit 693f49904f
1 changed files with 8 additions and 3 deletions

View File

@ -220,6 +220,13 @@ struct BitReader<'a, 'b> {
}
impl<'a, 'b> BitReader<'a, 'b> {
#[inline]
fn new(data: &'b mut &'a [u8]) -> Self {
Self {
bits: bitstream_io::BitReader::new(data),
}
}
#[inline]
fn read_bit(&mut self) -> io::Result<bool> {
self.bits.read_bit()
@ -318,9 +325,7 @@ impl<'a> Reader<'a> {
}
fn bits<'b>(&'b mut self) -> BitReader<'a, 'b> {
BitReader {
bits: bitstream_io::BitReader::new(&mut self.input),
}
BitReader::new(&mut self.input)
}
#[inline]