Skip to content

Commit

Permalink
Reduce diff
Browse files Browse the repository at this point in the history
  • Loading branch information
mxinden committed Sep 30, 2024
1 parent 91fbc6b commit f675eb9
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions neqo-common/src/codec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -336,8 +336,7 @@ impl<'a> Encoder<'a> {
#[allow(clippy::cast_possible_truncation)]
pub fn encode_vec_with<F: FnOnce(&mut Self)>(&mut self, n: usize, f: F) -> &mut Self {
let start = self.buf.len();
let len = self.buf.len();
self.buf.resize(len + n, 0);
self.buf.resize(self.buf.len() + n, 0);
f(self);
let len = self.buf.len() - start - n;
assert!(len < (1 << (n * 8)));
Expand Down Expand Up @@ -365,8 +364,7 @@ impl<'a> Encoder<'a> {
pub fn encode_vvec_with<F: FnOnce(&mut Self)>(&mut self, f: F) -> &mut Self {
let start = self.buf.len();
// Optimize for short buffers, reserve a single byte for the length.
let len = self.buf.len();
self.buf.resize(len + 1, 0);
self.buf.resize(self.buf.len() + 1, 0);
f(self);
let len = self.buf.len() - start - 1;

Expand Down

0 comments on commit f675eb9

Please sign in to comment.