Skip to content

Commit

Permalink
encoding: big-endian u16
Browse files Browse the repository at this point in the history
To reflect that big-endian is used in uvarint, ans also in upcoming msgpack.
  • Loading branch information
wkhere committed Apr 29, 2024
1 parent e15d086 commit 9d3591e
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions encoding.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@ package bcl
import "github.com/mohae/uvarint"

func u16ToBytes(p []byte, x uint16) {
p[0] = byte(x & 0xff)
p[1] = byte(x >> 8 & 0xff)

p[0] = byte(x >> 8 & 0xff)
p[1] = byte(x & 0xff)
}

func u16FromBytes(b []byte) uint16 {
return uint16(b[1])<<8 | uint16(b[0])
return uint16(b[0])<<8 | uint16(b[1])
}

func uvarintToBytes(p []byte, x uint64) int {
Expand Down

0 comments on commit 9d3591e

Please sign in to comment.