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

Method ReadVarUInt64

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

Source from the content-addressed store, hash-verified

585 }
586
587 public ulong ReadVarUInt64()
588 {
589 byte[] storage = _storage;
590 int cursor = _cursor;
591 int length = _length;
592 if (cursor >= length)
593 {
594 throw new OutOfBoundsException(cursor, 1, length);
595 }
596
597 byte first = storage[cursor];
598 if ((first & 0x80) == 0)
599 {
600 _cursor = cursor + 1;
601 return first;
602 }
603
604 cursor += 1;
605 ulong result = (ulong)(first & 0x7F);
606 int shift = 7;
607 for (var i = 1; i < 8; i++)
608 {
609 if (cursor >= length)
610 {
611 throw new OutOfBoundsException(cursor, 1, length);
612 }
613
614 byte b = storage[cursor];
615 cursor += 1;
616 result |= (ulong)(b & 0x7F) << shift;
617 if ((b & 0x80) == 0)
618 {
619 _cursor = cursor;
620 return result;
621 }
622
623 shift += 7;
624 }
625
626 if (cursor >= length)
627 {
628 throw new OutOfBoundsException(cursor, 1, length);
629 }
630
631 byte last = storage[cursor];
632 cursor += 1;
633 result |= (ulong)last << 56;
634 _cursor = cursor;
635 return result;
636 }
637
638 public ulong ReadVarUInt36Small()
639 {

Callers 10

ReadMethod · 0.80
SkipPayloadMethod · 0.80
ReadDataMethod · 0.80
ReadInt64FastPayloadMethod · 0.80
ReadScalarPayloadMethod · 0.80
ReadMethod · 0.80
CaseBufferVarMethod · 0.80

Calls

no outgoing calls

Tested by 4

CaseBufferVarMethod · 0.64