From bc998d034f45d1828a8663b2eed928faf22a7d01 Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Thu, 14 Sep 2017 17:11:35 +0000 Subject: libgo: update to go1.9 Reviewed-on: https://go-review.googlesource.com/63753 From-SVN: r252767 --- libgo/go/encoding/binary/binary.go | 3 ++- libgo/go/encoding/binary/binary_test.go | 24 ++++++++++++++++++++++++ libgo/go/encoding/binary/varint.go | 12 ++++++------ 3 files changed, 32 insertions(+), 7 deletions(-) (limited to 'libgo/go/encoding/binary') diff --git a/libgo/go/encoding/binary/binary.go b/libgo/go/encoding/binary/binary.go index 3834254..2d01a3c 100644 --- a/libgo/go/encoding/binary/binary.go +++ b/libgo/go/encoding/binary/binary.go @@ -152,7 +152,8 @@ func (bigEndian) GoString() string { return "binary.BigEndian" } // When reading into structs, the field data for fields with // blank (_) field names is skipped; i.e., blank field names // may be used for padding. -// When reading into a struct, all non-blank fields must be exported. +// When reading into a struct, all non-blank fields must be exported +// or Read may panic. // // The error is EOF only if no bytes were read. // If an EOF happens after reading some but not all the bytes, diff --git a/libgo/go/encoding/binary/binary_test.go b/libgo/go/encoding/binary/binary_test.go index fc7f276..0547bee 100644 --- a/libgo/go/encoding/binary/binary_test.go +++ b/libgo/go/encoding/binary/binary_test.go @@ -500,3 +500,27 @@ func BenchmarkWriteSlice1000Int32s(b *testing.B) { } b.StopTimer() } + +func BenchmarkPutUint16(b *testing.B) { + buf := [2]byte{} + b.SetBytes(2) + for i := 0; i < b.N; i++ { + BigEndian.PutUint16(buf[:], uint16(i)) + } +} + +func BenchmarkPutUint32(b *testing.B) { + buf := [4]byte{} + b.SetBytes(4) + for i := 0; i < b.N; i++ { + BigEndian.PutUint32(buf[:], uint32(i)) + } +} + +func BenchmarkPutUint64(b *testing.B) { + buf := [8]byte{} + b.SetBytes(8) + for i := 0; i < b.N; i++ { + BigEndian.PutUint64(buf[:], uint64(i)) + } +} diff --git a/libgo/go/encoding/binary/varint.go b/libgo/go/encoding/binary/varint.go index d7a75f9..bcb8ac9 100644 --- a/libgo/go/encoding/binary/varint.go +++ b/libgo/go/encoding/binary/varint.go @@ -53,9 +53,9 @@ func PutUvarint(buf []byte, x uint64) int { // number of bytes read (> 0). If an error occurred, the value is 0 // and the number of bytes n is <= 0 meaning: // -// n == 0: buf too small -// n < 0: value larger than 64 bits (overflow) -// and -n is the number of bytes read +// n == 0: buf too small +// n < 0: value larger than 64 bits (overflow) +// and -n is the number of bytes read // func Uvarint(buf []byte) (uint64, int) { var x uint64 @@ -87,9 +87,9 @@ func PutVarint(buf []byte, x int64) int { // number of bytes read (> 0). If an error occurred, the value is 0 // and the number of bytes n is <= 0 with the following meaning: // -// n == 0: buf too small -// n < 0: value larger than 64 bits (overflow) -// and -n is the number of bytes read +// n == 0: buf too small +// n < 0: value larger than 64 bits (overflow) +// and -n is the number of bytes read // func Varint(buf []byte) (int64, int) { ux, n := Uvarint(buf) // ok to continue in presence of error -- cgit v1.1