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

Function read_varint_with_start

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

Read a big-endian varint with start marker (0x80).

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

Source from the content-addressed store, hash-verified

64
65/// Read a big-endian varint with start marker (0x80).
66pub fn read_varint_with_start(data: &[u8], pos: &mut usize) -> Option<u32> {
67 if *pos >= data.len() {
68 return None;
69 }
70 let first = data[*pos];
71 if first & 0x80 == 0 {
72 return None;
73 }
74 *pos += 1;
75 let mut val = (first & 0x3f) as u32;
76 let mut cont = first & 0x40 != 0;
77 while cont && *pos < data.len() {
78 let b = data[*pos];
79 *pos += 1;
80 val = (val << 6) | (b & 0x3f) as u32;
81 cont = b & 0x40 != 0;
82 }
83 Some(val)
84}
85
86/// Read a big-endian varint (no start marker).
87pub fn read_varint(data: &[u8], pos: &mut usize) -> Option<u32> {

Callers 2

find_exception_handlerFunction · 0.85
decode_exception_tableFunction · 0.85

Calls 2

SomeClass · 0.50
lenMethod · 0.45

Tested by

no test coverage detected