Skip to content

Commit

Permalink
Address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Mallets committed Mar 18, 2024
1 parent 4d2d54c commit 3edc302
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 123 deletions.
120 changes: 2 additions & 118 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions commons/zenoh-codec/src/core/zint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,13 +112,13 @@ where
fn write(self, writer: &mut W, mut x: u64) -> Self::Output {
writer.with_slot(VLE_LEN, move |buffer| {
let mut len = 0;
while (x & !0x7f) != 0 {
while (x & !0x7f_u64) != 0 {
// SAFETY: buffer is guaranteed to be VLE_LEN long where VLE_LEN is
// the maximum number of bytes a VLE can take once encoded.
// I.e.: x is shifted 7 bits to the right every iteration,
// the loop is at most VLE_LEN iterations.
unsafe {
*buffer.get_unchecked_mut(len) = (x as u8) | 0x80;
*buffer.get_unchecked_mut(len) = (x as u8) | 0x80_u8;
}
len += 1;
x >>= 7;
Expand All @@ -144,15 +144,15 @@ where

fn read(self, reader: &mut R) -> Result<u64, Self::Error> {
let mut b = reader.read_u8()?;
if (b & 0x80) == 0 {
if (b & 0x80_u8) == 0 {
return Ok(b as u64);
}

let mut v = 0;
let mut i = 0;
// 7 * VLE_LEN is beyond the maximum number of shift bits
while (b & 0x80) != 0 && i != 7 * VLE_LEN {
v |= ((b & 0x7f) as u64) << i;
while (b & 0x80_u8) != 0 && i != 7 * VLE_LEN {
v |= ((b & 0x7f_u8) as u64) << i;
b = reader.read_u8()?;
i += 7;
}
Expand Down

0 comments on commit 3edc302

Please sign in to comment.