| 992 | } |
| 993 | |
| 994 | func (b *ByteBuffer) readVaruint36SmallFast() uint64 { |
| 995 | // Single instruction load using unsafe pointer cast (little-endian only) |
| 996 | // On big-endian systems, use binary.LittleEndian which the compiler optimizes |
| 997 | var bulk uint64 |
| 998 | if isLittleEndian { |
| 999 | bulk = *(*uint64)(unsafe.Pointer(&b.data[b.readerIndex])) |
| 1000 | } else { |
| 1001 | bulk = binary.LittleEndian.Uint64(b.data[b.readerIndex:]) |
| 1002 | } |
| 1003 | |
| 1004 | result := bulk & 0x7F |
| 1005 | readLen := 1 |
| 1006 | |
| 1007 | if (bulk & 0x80) != 0 { |
| 1008 | readLen = 2 |
| 1009 | result |= (bulk >> 1) & 0x3F80 |
| 1010 | if (bulk & 0x8000) != 0 { |
| 1011 | readLen = 3 |
| 1012 | result |= (bulk >> 2) & 0x1FC000 |
| 1013 | if (bulk & 0x800000) != 0 { |
| 1014 | readLen = 4 |
| 1015 | result |= (bulk >> 3) & 0xFE00000 |
| 1016 | if (bulk & 0x80000000) != 0 { |
| 1017 | readLen = 5 |
| 1018 | result |= (bulk >> 4) & 0xFF0000000 |
| 1019 | } |
| 1020 | } |
| 1021 | } |
| 1022 | } |
| 1023 | b.readerIndex += readLen |
| 1024 | return result |
| 1025 | } |
| 1026 | |
| 1027 | func (b *ByteBuffer) readVaruint36SmallSlow(err *Error) uint64 { |
| 1028 | var result uint64 |