Minor style change in leb128.odin

This commit is contained in:
gingerBill
2022-05-12 15:59:15 +01:00
parent d224679619
commit 3fdb3dd767
+4 -6
View File
@@ -13,7 +13,7 @@ package varint
// In theory we should use the bigint package. In practice, varints bigger than this indicate a corrupted file.
// Instead we'll set limits on the values we'll encode/decode
// 18 * 7 bits = 126, which means that a possible 19th byte may at most be `0b0000_0011`.
LEB128_MAX_BYTES :: 19
LEB128_MAX_BYTES :: 19
Error :: enum {
None = 0,
@@ -132,14 +132,12 @@ encode_uleb128 :: proc(buf: []u8, val: u128) -> (size: int, err: Error) {
return
}
@(private)
SIGN_MASK :: (i128(1) << 121) // sign extend mask
// Encode `val` into `buf` as a signed LEB128 encoded series of bytes.
// `buf` must be appropriately sized.
encode_ileb128 :: proc(buf: []u8, val: i128) -> (size: int, err: Error) {
val := val
more := true
SIGN_MASK :: i128(1) << 121 // sign extend mask
val, more := val, true
for more {
size += 1