]> Cypherpunks repositories - gostls13.git/commitdiff
encoding/binary: returns length of bool slice in intDataSize
authorJoe Kyo <xunianzu@gmail.com>
Tue, 8 May 2018 13:00:36 +0000 (21:00 +0800)
committerIan Lance Taylor <iant@golang.org>
Tue, 8 May 2018 14:48:50 +0000 (14:48 +0000)
intDataSize should return length of bool slice, so functions
Read and Write can use the fast path to process bool slice.

Change-Id: I8cd275e3ffea82024850662d86caca64bd91bf70
Reviewed-on: https://go-review.googlesource.com/112135
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>

src/encoding/binary/binary.go

index 22fd7f2a8005dcc4ae76179a5e227881a5715249..85b3bc2295dc6dc39a31ac2be7220cf548bcc279 100644 (file)
@@ -665,6 +665,8 @@ func intDataSize(data interface{}) int {
        switch data := data.(type) {
        case bool, int8, uint8, *bool, *int8, *uint8:
                return 1
+       case []bool:
+               return len(data)
        case []int8:
                return len(data)
        case []uint8: