MCPcopy Index your code
hub / github.com/RustPython/RustPython / read_varint

Function read_varint

crates/compiler-core/src/varint.rs:87–102  ·  view source on GitHub ↗

Read a big-endian varint (no start marker).

(data: &[u8], pos: &mut usize)

Source from the content-addressed store, hash-verified

85
86/// Read a big-endian varint (no start marker).
87pub fn read_varint(data: &[u8], pos: &mut usize) -> Option<u32> {
88 if *pos >= data.len() {
89 return None;
90 }
91 let first = data[*pos];
92 *pos += 1;
93 let mut val = (first & 0x3f) as u32;
94 let mut cont = first & 0x40 != 0;
95 while cont && *pos < data.len() {
96 let b = data[*pos];
97 *pos += 1;
98 val = (val << 6) | (b & 0x3f) as u32;
99 cont = b & 0x40 != 0;
100 }
101 Some(val)
102}
103
104#[cfg(test)]
105mod tests {

Callers 2

find_exception_handlerFunction · 0.70
decode_exception_tableFunction · 0.70

Calls 2

SomeClass · 0.50
lenMethod · 0.45

Tested by

no test coverage detected