Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 7 additions & 15 deletions internal/pgio/write.go
Original file line number Diff line number Diff line change
@@ -1,26 +1,18 @@
package pgio

import "encoding/binary"

func AppendUint16(buf []byte, n uint16) []byte {
wp := len(buf)
buf = append(buf, 0, 0)
binary.BigEndian.PutUint16(buf[wp:], n)
return buf
return append(buf, byte(n>>8), byte(n))
}

func AppendUint32(buf []byte, n uint32) []byte {
wp := len(buf)
buf = append(buf, 0, 0, 0, 0)
binary.BigEndian.PutUint32(buf[wp:], n)
return buf
return append(buf, byte(n>>24), byte(n>>16), byte(n>>8), byte(n))
}

func AppendUint64(buf []byte, n uint64) []byte {
wp := len(buf)
buf = append(buf, 0, 0, 0, 0, 0, 0, 0, 0)
binary.BigEndian.PutUint64(buf[wp:], n)
return buf
return append(buf,
byte(n>>56), byte(n>>48), byte(n>>40), byte(n>>32),
byte(n>>24), byte(n>>16), byte(n>>8), byte(n),
)
}

func AppendInt16(buf []byte, n int16) []byte {
Expand All @@ -36,5 +28,5 @@ func AppendInt64(buf []byte, n int64) []byte {
}

func SetInt32(buf []byte, n int32) {
binary.BigEndian.PutUint32(buf, uint32(n))
*(*[4]byte)(buf) = [4]byte{byte(n >> 24), byte(n >> 16), byte(n >> 8), byte(n)}
}