Skip to content

Commit

Permalink
Remove unnecessary Vec<u8> from byte-sequence parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
apasel422 committed Feb 20, 2025
1 parent 46e49bb commit f45a6a0
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -327,16 +327,17 @@ impl<'a> Parser<'a> {
return Err("parse_byte_seq: first char is not ':'");
}

let mut b64_content = vec![];
let start = self.index;

loop {
match self.next() {
Some(b':') => break,
Some(c) => b64_content.push(c),
Some(_) => {}
None => return Err("parse_byte_seq: no closing ':'"),
}
}

match base64::Engine::decode(&utils::BASE64, b64_content) {
match base64::Engine::decode(&utils::BASE64, &self.input[start..self.index - 1]) {
Ok(content) => Ok(content),
Err(_) => Err("parse_byte_seq: decoding error"),
}
Expand Down

0 comments on commit f45a6a0

Please sign in to comment.