Skip to content

Commit

Permalink
improve encode_varint performance by bounding its loop (#940)
Browse files Browse the repository at this point in the history
  • Loading branch information
mumbleskates authored Mar 15, 2024
1 parent 9f24f38 commit 145fd47
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/encoding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ pub fn encode_varint<B>(mut value: u64, buf: &mut B)
where
B: BufMut,
{
loop {
// Varints are never more than 10 bytes
for _ in 0..10 {
if value < 0x80 {
buf.put_u8(value as u8);
break;
Expand Down

0 comments on commit 145fd47

Please sign in to comment.