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

Method ReadVarUInt32

csharp/src/Fory/ByteBuffer.cs:543–585  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

541 }
542
543 public uint ReadVarUInt32()
544 {
545 byte[] storage = _storage;
546 int cursor = _cursor;
547 int length = _length;
548 if (cursor >= length)
549 {
550 throw new OutOfBoundsException(cursor, 1, length);
551 }
552
553 byte first = storage[cursor];
554 if ((first & 0x80) == 0)
555 {
556 _cursor = cursor + 1;
557 return first;
558 }
559
560 cursor += 1;
561 uint result = (uint)(first & 0x7F);
562 int shift = 7;
563 while (true)
564 {
565 if (cursor >= length)
566 {
567 throw new OutOfBoundsException(cursor, 1, length);
568 }
569
570 byte b = storage[cursor];
571 cursor += 1;
572 result |= (uint)(b & 0x7F) << shift;
573 if ((b & 0x80) == 0)
574 {
575 _cursor = cursor;
576 return result;
577 }
578
579 shift += 7;
580 if (shift > 28)
581 {
582 throw new EncodingException("varuint32 overflow");
583 }
584 }
585 }
586
587 public ulong ReadVarUInt64()
588 {

Callers 15

SkipPayloadMethod · 0.80
SkipPackedArrayMethod · 0.80
SkipListOrSetMethod · 0.80
SkipMapMethod · 0.80
ReadDataMethod · 0.80
ReadDataMethod · 0.80
ReadCollectionDataMethod · 0.80
ReadInt64FastPayloadMethod · 0.80
ReadScalarPayloadMethod · 0.80
ReadMethod · 0.80
ReadMapMethod · 0.80

Calls

no outgoing calls

Tested by 9

TypeMetaBodyOffsetMethod · 0.64
RewriteRootUserTypeIdMethod · 0.64
CaseBufferMethod · 0.64
CaseBufferVarMethod · 0.64