MCPcopy Create free account
hub / github.com/apache/fory / write_var_u36_small

Method write_var_u36_small

rust/fory-core/src/buffer.rs:485–519  ·  view source on GitHub ↗
(&mut self, value: u64)

Source from the content-addressed store, hash-verified

483
484 #[inline(always)]
485 pub fn write_var_u36_small(&mut self, value: u64) {
486 assert!(
487 value < (1u64 << 36),
488 "value too large for 36-bit variable-length integer"
489 );
490 if value < 0x80 {
491 self.bf.push(value as u8);
492 } else if value < 0x4000 {
493 let b0 = ((value & 0x7F) as u8) | 0x80;
494 let b1 = (value >> 7) as u8;
495 let combined = ((b1 as u16) << 8) | (b0 as u16);
496 self.write_u16(combined);
497 } else if value < 0x200000 {
498 let b0 = (value & 0x7F) | 0x80;
499 let b1 = ((value >> 7) & 0x7F) | 0x80;
500 let b2 = value >> 14;
501 let combined = b0 | (b1 << 8) | (b2 << 16);
502 self.write_u32(combined as u32);
503 } else if value < 0x10000000 {
504 let b0 = (value & 0x7F) | 0x80;
505 let b1 = ((value >> 7) & 0x7F) | 0x80;
506 let b2 = ((value >> 14) & 0x7F) | 0x80;
507 let b3 = value >> 21;
508 let combined = b0 | (b1 << 8) | (b2 << 16) | (b3 << 24);
509 self.write_u32(combined as u32);
510 } else {
511 let b0 = (value & 0x7F) | 0x80;
512 let b1 = ((value >> 7) & 0x7F) | 0x80;
513 let b2 = ((value >> 14) & 0x7F) | 0x80;
514 let b3 = ((value >> 21) & 0x7F) | 0x80;
515 let b4 = value >> 28;
516 let combined = b0 | (b1 << 8) | (b2 << 16) | (b3 << 24) | (b4 << 32);
517 self.write_u64(combined);
518 }
519 }
520}
521
522#[derive(Default)]

Callers 2

fory_write_dataMethod · 0.80
test_var_u36_smallFunction · 0.80

Calls 3

write_u16Method · 0.80
write_u32Method · 0.80
write_u64Method · 0.80

Tested by 1

test_var_u36_smallFunction · 0.64