diff options
Diffstat (limited to 'leaf_alts.go')
| -rw-r--r-- | leaf_alts.go | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/leaf_alts.go b/leaf_alts.go index c51f7df..70513ab 100644 --- a/leaf_alts.go +++ b/leaf_alts.go @@ -41,3 +41,14 @@ func bePutUint32(b []byte, v uint32) { b[2] = byte(v >> 8) b[3] = byte(v) } + +func leUint16(b []byte) uint16 { + _ = b[1] // bounds check hint to compiler; see golang.org/issue/14808 + return uint16(b[0]) | uint16(b[1])<<8 +} + +func lePutUint16(b []byte, v uint16) { + _ = b[1] // early bounds check to guarantee safety of writes below + b[0] = byte(v) + b[1] = byte(v >> 8) +} |
