aboutsummaryrefslogtreecommitdiff
path: root/libgo/go/encoding/binary
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@golang.org>2017-09-14 17:11:35 +0000
committerIan Lance Taylor <ian@gcc.gnu.org>2017-09-14 17:11:35 +0000
commitbc998d034f45d1828a8663b2eed928faf22a7d01 (patch)
tree8d262a22ca7318f4bcd64269fe8fe9e45bcf8d0f /libgo/go/encoding/binary
parenta41a6142df74219f596e612d3a7775f68ca6e96f (diff)
downloadgcc-bc998d034f45d1828a8663b2eed928faf22a7d01.zip
gcc-bc998d034f45d1828a8663b2eed928faf22a7d01.tar.gz
gcc-bc998d034f45d1828a8663b2eed928faf22a7d01.tar.bz2
libgo: update to go1.9
Reviewed-on: https://go-review.googlesource.com/63753 From-SVN: r252767
Diffstat (limited to 'libgo/go/encoding/binary')
-rw-r--r--libgo/go/encoding/binary/binary.go3
-rw-r--r--libgo/go/encoding/binary/binary_test.go24
-rw-r--r--libgo/go/encoding/binary/varint.go12
3 files changed, 32 insertions, 7 deletions
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