aboutsummaryrefslogtreecommitdiff
path: root/src/pkg/encoding/binary
diff options
context:
space:
mode:
authorRob Pike <r@golang.org>2013-08-10 09:11:58 +1000
committerRob Pike <r@golang.org>2013-08-10 09:11:58 +1000
commit556b337ece484d34d3dee1419579ca89475fcefc (patch)
treec87ca99afed03af78a680106508528765dee271b /src/pkg/encoding/binary
parentb78410bda13cc10c1e59dfdcc935b3155450b44e (diff)
downloadgo-556b337ece484d34d3dee1419579ca89475fcefc.tar.xz
encoding/binary: better description for intReadSize
It used to be called intDestSize; the new name is better too. R=bradfitz CC=golang-dev https://golang.org/cl/12713043
Diffstat (limited to 'src/pkg/encoding/binary')
-rw-r--r--src/pkg/encoding/binary/binary.go7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/pkg/encoding/binary/binary.go b/src/pkg/encoding/binary/binary.go
index 107b80b9fe..a6bed8b34d 100644
--- a/src/pkg/encoding/binary/binary.go
+++ b/src/pkg/encoding/binary/binary.go
@@ -135,7 +135,7 @@ func (bigEndian) GoString() string { return "binary.BigEndian" }
// may be used for padding.
func Read(r io.Reader, order ByteOrder, data interface{}) error {
// Fast path for basic types and slices.
- if n := intDestSize(data); n != 0 {
+ if n := intReadSize(data); n != 0 {
var b [8]byte
var bs []byte
if n > len(b) {
@@ -609,8 +609,9 @@ func (e *encoder) skip(v reflect.Value) {
e.buf = e.buf[n:]
}
-// intDestSize returns the size of the data required to represent the data when encoded.
-func intDestSize(data interface{}) int {
+// intReadSize returns the size of the data required to represent the data when encoded.
+// It returns zero if the type cannot be implemented by the fast path in Read.
+func intReadSize(data interface{}) int {
switch data := data.(type) {
case *int8, *uint8:
return 1