aboutsummaryrefslogtreecommitdiff
path: root/src/encoding/binary
AgeCommit message (Collapse)Author
2020-08-06[release-branch.go1.13-security] encoding/binary: read at most ↵Katie Hockman
MaxVarintLen64 bytes in ReadUvarint This CL ensures that ReadUvarint consumes only a limited amount of input (instead of an unbounded amount). On some inputs, ReadUvarint could read an arbitrary number of bytes before deciding to return an overflow error. After this CL, ReadUvarint returns that same overflow error sooner, after reading at most MaxVarintLen64 bytes. Fix authored by Robert Griesemer and Filippo Valsorda. Thanks to Diederik Loerakker, Jonny Rhea, Raúl Kripalani, and Preston Van Loon for reporting this. Fixes CVE-2020-16845 Change-Id: Ie0cb15972f14c38b7cf7af84c45c4ce54909bb8f Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/812099 Reviewed-by: Filippo Valsorda <valsorda@google.com> Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/812324
2019-05-06all: simplify code using "gofmt -s -w"Shulhan
Most changes are removing redundant declaration of type when direct instantiating value of map or slice, e.g. []T{T{}} become []T{{}}. Small changes are removing the high order of subslice if its value is the length of slice itself, e.g. T[:len(T)] become T[:]. The following file is excluded due to incompatibility with go1.4, - src/cmd/compile/internal/gc/ssa.go Change-Id: Id3abb09401795ce1e6da591a89749cba8502fb26 Reviewed-on: https://go-review.googlesource.com/c/go/+/166437 Run-TryBot: Dave Cheney <dave@cheney.net> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-09-04encoding/binary: simplify Read and WriteJosh Bleecher Snyder
There's no need to manually manage the backing slice for bs. Removing it simplifies the code, removes some allocations, and speeds it up slightly. Fixes #27403 name old time/op new time/op delta ReadSlice1000Int32s-8 6.39µs ± 1% 6.31µs ± 1% -1.37% (p=0.000 n=27+27) ReadStruct-8 1.25µs ± 2% 1.23µs ± 2% -1.06% (p=0.003 n=30+29) ReadInts-8 301ns ± 0% 297ns ± 1% -1.21% (p=0.000 n=27+30) WriteInts-8 325ns ± 1% 320ns ± 1% -1.59% (p=0.000 n=26+29) WriteSlice1000Int32s-8 6.60µs ± 0% 6.52µs ± 0% -1.23% (p=0.000 n=28+27) PutUint16-8 0.72ns ± 2% 0.71ns ± 2% ~ (p=0.286 n=30+30) PutUint32-8 0.71ns ± 1% 0.71ns ± 0% -0.42% (p=0.003 n=30+25) PutUint64-8 0.78ns ± 2% 0.78ns ± 0% -0.55% (p=0.001 n=30+27) LittleEndianPutUint16-8 0.57ns ± 0% 0.57ns ± 0% ~ (all equal) LittleEndianPutUint32-8 0.57ns ± 0% 0.57ns ± 0% ~ (all equal) LittleEndianPutUint64-8 0.57ns ± 0% 0.57ns ± 0% ~ (all equal) PutUvarint32-8 23.1ns ± 1% 23.1ns ± 1% ~ (p=0.925 n=26+29) PutUvarint64-8 57.5ns ± 2% 57.3ns ± 1% ~ (p=0.338 n=30+26) [Geo mean] 23.0ns 22.9ns -0.61% name old speed new speed delta ReadSlice1000Int32s-8 626MB/s ± 1% 634MB/s ± 1% +1.38% (p=0.000 n=27+27) ReadStruct-8 60.2MB/s ± 2% 60.8MB/s ± 2% +1.08% (p=0.002 n=30+29) ReadInts-8 100MB/s ± 1% 101MB/s ± 1% +1.24% (p=0.000 n=27+30) WriteInts-8 92.2MB/s ± 1% 93.6MB/s ± 1% +1.56% (p=0.000 n=26+29) WriteSlice1000Int32s-8 606MB/s ± 0% 614MB/s ± 0% +1.24% (p=0.000 n=28+27) PutUint16-8 2.80GB/s ± 1% 2.80GB/s ± 1% ~ (p=0.095 n=28+29) PutUint32-8 5.61GB/s ± 1% 5.62GB/s ± 1% ~ (p=0.069 n=27+28) PutUint64-8 10.2GB/s ± 1% 10.2GB/s ± 0% +0.15% (p=0.039 n=27+27) LittleEndianPutUint16-8 3.50GB/s ± 1% 3.50GB/s ± 1% ~ (p=0.552 n=30+29) LittleEndianPutUint32-8 7.01GB/s ± 1% 7.02GB/s ± 1% ~ (p=0.160 n=29+27) LittleEndianPutUint64-8 14.0GB/s ± 1% 14.0GB/s ± 1% ~ (p=0.413 n=29+29) PutUvarint32-8 174MB/s ± 1% 173MB/s ± 1% ~ (p=0.648 n=25+30) PutUvarint64-8 139MB/s ± 2% 140MB/s ± 1% ~ (p=0.271 n=30+26) [Geo mean] 906MB/s 911MB/s +0.55% name old alloc/op new alloc/op delta ReadSlice1000Int32s-8 4.14kB ± 0% 4.13kB ± 0% -0.19% (p=0.000 n=30+30) ReadStruct-8 200B ± 0% 200B ± 0% ~ (all equal) ReadInts-8 64.0B ± 0% 32.0B ± 0% -50.00% (p=0.000 n=30+30) WriteInts-8 112B ± 0% 64B ± 0% -42.86% (p=0.000 n=30+30) WriteSlice1000Int32s-8 4.14kB ± 0% 4.13kB ± 0% -0.19% (p=0.000 n=30+30) PutUint16-8 0.00B 0.00B ~ (all equal) PutUint32-8 0.00B 0.00B ~ (all equal) PutUint64-8 0.00B 0.00B ~ (all equal) LittleEndianPutUint16-8 0.00B 0.00B ~ (all equal) LittleEndianPutUint32-8 0.00B 0.00B ~ (all equal) LittleEndianPutUint64-8 0.00B 0.00B ~ (all equal) PutUvarint32-8 0.00B 0.00B ~ (all equal) PutUvarint64-8 0.00B 0.00B ~ (all equal) [Geo mean] 476B 370B -22.22% name old allocs/op new allocs/op delta ReadSlice1000Int32s-8 3.00 ± 0% 2.00 ± 0% -33.33% (p=0.000 n=30+30) ReadStruct-8 16.0 ± 0% 16.0 ± 0% ~ (all equal) ReadInts-8 8.00 ± 0% 8.00 ± 0% ~ (all equal) WriteInts-8 14.0 ± 0% 14.0 ± 0% ~ (all equal) WriteSlice1000Int32s-8 3.00 ± 0% 2.00 ± 0% -33.33% (p=0.000 n=30+30) PutUint16-8 0.00 0.00 ~ (all equal) PutUint32-8 0.00 0.00 ~ (all equal) PutUint64-8 0.00 0.00 ~ (all equal) LittleEndianPutUint16-8 0.00 0.00 ~ (all equal) LittleEndianPutUint32-8 0.00 0.00 ~ (all equal) LittleEndianPutUint64-8 0.00 0.00 ~ (all equal) PutUvarint32-8 0.00 0.00 ~ (all equal) PutUvarint64-8 0.00 0.00 ~ (all equal) [Geo mean] 6.94 5.90 -14.97% Change-Id: I3790b93e4190d98621d5f2c47e42929a18f56c2e Reviewed-on: https://go-review.googlesource.com/133135 Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-05-08encoding/binary: returns length of bool slice in intDataSizeJoe Kyo
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>
2018-03-06encoding/binary: use an offset instead of slicingJosh Bleecher Snyder
While running make.bash, over 5% of all pointer writes come from encoding/binary doing struct reads. This change replaces slicing during such reads with an offset. This avoids updating the slice pointer with every struct field read or write. This has no impact when the write barrier is off. Running the benchmarks with GOGC=1, however, shows significant improvement: name old time/op new time/op delta ReadStruct-8 13.2µs ± 6% 10.1µs ± 5% -23.24% (p=0.000 n=10+10) name old speed new speed delta ReadStruct-8 5.69MB/s ± 6% 7.40MB/s ± 5% +30.18% (p=0.000 n=10+10) Change-Id: I22904263196bfeddc38abe8989428e263aee5253 Reviewed-on: https://go-review.googlesource.com/98757 Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-11-15encoding/binary: make new example a bit more idiomaticRuss Cox
Mainly get rid of the weird zero-value struct literal, but while we're here also group and order things a bit better: first the reader, then the data, then the call (which takes reader then data). Change-Id: I901b0661d85d8eaa0807e4482aac66500ca996c7 Reviewed-on: https://go-review.googlesource.com/78118 Run-TryBot: Russ Cox <rsc@golang.org> Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
2017-11-03cmd/compile: add rules to improve consecutive byte loads and stores on ppc64leLynn Boger
This adds new rules to recognize consecutive byte loads and stores and lowers them to loads and stores such as lhz, lwz, ld, sth, stw, std. This change only covers the little endian cases on little endian machines, such as is found in encoding/binary UintXX or PutUintXX for little endian. Big endian will be done later. Updates were also made to binary_test.go to allow the benchmark for Uint and PutUint to actually use those functions because the way they were written, those functions were being optimized out. Testcases were also added to cmd/compile/internal/gc/asm_test.go. Updates #22496 The following improvement can be found in golang.org/x/crypto poly1305: Benchmark64-16 142 114 -19.72% Benchmark1K-16 1717 1424 -17.06% Benchmark64Unaligned-16 142 113 -20.42% Benchmark1KUnaligned-16 1721 1428 -17.02% chacha20poly1305: BenchmarkChacha20Poly1305Open_64-16 1012 885 -12.55% BenchmarkChacha20Poly1305Seal_64-16 971 836 -13.90% BenchmarkChacha20Poly1305Open_1350-16 11113 9539 -14.16% BenchmarkChacha20Poly1305Seal_1350-16 11013 9392 -14.72% BenchmarkChacha20Poly1305Open_8K-16 61074 53431 -12.51% BenchmarkChacha20Poly1305Seal_8K-16 61214 54806 -10.47% Other improvements of around 10% found in crypto/tls. Results after updating encoding/binary/binary_test.go: BenchmarkLittleEndianPutUint64-16 1.87 0.93 -50.27% BenchmarkLittleEndianPutUint32-16 1.19 0.93 -21.85% BenchmarkLittleEndianPutUint16-16 1.16 1.03 -11.21% Change-Id: I7bbe2fbcbd11362d58662fecd907a0c07e6ca2fb Reviewed-on: https://go-review.googlesource.com/74410 Run-TryBot: Lynn Boger <laboger@linux.vnet.ibm.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Michael Munday <mike.munday@ibm.com>
2017-08-12encoding/binary: add example for Read multiMark Wolfe
Change-Id: I27ff99aa7abb070f6ae79c8f964aa9bd6a83b89d Reviewed-on: https://go-review.googlesource.com/53730 Reviewed-by: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-08-03encoding/binary: add examples for varint functionsAxel Wagner
Change-Id: I191f6e46b452fadde9f641140445d843b0c7d534 Reviewed-on: https://go-review.googlesource.com/48604 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-07-15encoding/binary: add examples for ByteOrder functionsRoss Light
Change-Id: Iec9a7bf61566ee08c4d15adb39d43c7a29c79122 Reviewed-on: https://go-review.googlesource.com/48962 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
2017-06-29encoding/binary: clarify the repercussions for not following the docsBrad Fitzpatrick
Fixes #19794 Change-Id: I462cbc432fe9d4a9e6e79a9833b0013d82a0780e Reviewed-on: https://go-review.googlesource.com/47093 Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-06-27encoding/binary: improve comment formatting consistencyDmitri Shuralyov
Use 2 slashes, space, then tab. This is more consistent, and removes inadvertent leading space. Change-Id: I383770ed4eb8ac17c78c7ae5675b553d4fb70b1e Reviewed-on: https://go-review.googlesource.com/46726 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-02-14cmd/compile/internal/ssa: combine 2 byte loads + shifts into word load + ↵Kirill Smelkov
rolw 8 on AMD64 ... and same for stores. This does for binary.BigEndian.Uint16() what was already done for Uint32 and Uint64 with BSWAP in 10f75748 (CL 32222). Here is how generated code changes e.g. for the following function (omitting saying the same prologue/epilogue): func get16(b [2]byte) uint16 { return binary.BigEndian.Uint16(b[:]) } "".get16 t=1 size=21 args=0x10 locals=0x0 // before 0x0000 00000 (x.go:15) MOVBLZX "".b+9(FP), AX 0x0005 00005 (x.go:15) MOVBLZX "".b+8(FP), CX 0x000a 00010 (x.go:15) SHLL $8, CX 0x000d 00013 (x.go:15) ORL CX, AX // after 0x0000 00000 (x.go:15) MOVWLZX "".b+8(FP), AX 0x0005 00005 (x.go:15) ROLW $8, AX encoding/binary is speedup overall a bit: name old time/op new time/op delta ReadSlice1000Int32s-4 4.83µs ± 0% 4.83µs ± 0% ~ (p=0.206 n=4+5) ReadStruct-4 1.29µs ± 2% 1.28µs ± 1% -1.27% (p=0.032 n=4+5) ReadInts-4 384ns ± 1% 385ns ± 1% ~ (p=0.968 n=4+5) WriteInts-4 534ns ± 3% 526ns ± 0% -1.54% (p=0.048 n=4+5) WriteSlice1000Int32s-4 5.02µs ± 0% 5.11µs ± 3% ~ (p=0.175 n=4+5) PutUint16-4 0.59ns ± 0% 0.49ns ± 2% -16.95% (p=0.016 n=4+5) PutUint32-4 0.52ns ± 0% 0.52ns ± 0% ~ (all equal) PutUint64-4 0.53ns ± 0% 0.53ns ± 0% ~ (all equal) PutUvarint32-4 19.9ns ± 0% 19.9ns ± 1% ~ (p=0.556 n=4+5) PutUvarint64-4 54.5ns ± 1% 54.2ns ± 0% ~ (p=0.333 n=4+5) name old speed new speed delta ReadSlice1000Int32s-4 829MB/s ± 0% 828MB/s ± 0% ~ (p=0.190 n=4+5) ReadStruct-4 58.0MB/s ± 2% 58.7MB/s ± 1% +1.30% (p=0.032 n=4+5) ReadInts-4 78.0MB/s ± 1% 77.8MB/s ± 1% ~ (p=0.968 n=4+5) WriteInts-4 56.1MB/s ± 3% 57.0MB/s ± 0% ~ (p=0.063 n=4+5) WriteSlice1000Int32s-4 797MB/s ± 0% 783MB/s ± 3% ~ (p=0.190 n=4+5) PutUint16-4 3.37GB/s ± 0% 4.07GB/s ± 2% +20.83% (p=0.016 n=4+5) PutUint32-4 7.73GB/s ± 0% 7.72GB/s ± 0% ~ (p=0.556 n=4+5) PutUint64-4 15.1GB/s ± 0% 15.1GB/s ± 0% ~ (p=0.905 n=4+5) PutUvarint32-4 201MB/s ± 0% 201MB/s ± 0% ~ (p=0.905 n=4+5) PutUvarint64-4 147MB/s ± 1% 147MB/s ± 0% ~ (p=0.286 n=4+5) ( "a bit" only because most of the time is spent in reflection-like things there, not actual bytes decoding. Even for direct PutUint16 benchmark the looping adds overhead and lowers visible benefit. For code-generated encoders / decoders actual effect is more than 20% ) Adding Uint32 and Uint64 raw benchmarks too for completeness. NOTE I had to adjust load-combining rule for bswap case to match first 2 bytes loads as result of "2-bytes load+shift" -> "loadw + rorw 8" rewrite. Reason is: for loads+shift, even e.g. into uint16 var var b []byte var v uin16 v = uint16(b[1]) | uint16(b[0])<<8 the compiler eventually generates L(ong) shift - SHLLconst [8], probably because it is more straightforward / other reasons to work on the whole register. This way 2 bytes rewriting rule is using SHLLconst (not SHLWconst) in its pattern, and then it always gets matched first, even if 2-byte rule comes syntactically after 4-byte rule in AMD64.rules because 4-bytes rule seemingly needs more applyRewrite() cycles to trigger. If 2-bytes rule gets matched for inner half of var b []byte var v uin32 v = uint32(b[3]) | uint32(b[2])<<8 | uint32(b[1])<<16 | uint32(b[0])<<24 and we keep 4-byte load rule unchanged, the result will be MOVW + RORW $8 and then series of byte loads and shifts - not one MOVL + BSWAPL. There is no such problem for stores: there compiler, since it probably knows store destination is 2 bytes wide, uses SHRWconst 8 (not SHRLconst 8) and thus 2-byte store rule is not a subset of rule for 4-byte stores. Fixes #17151 (int16 was last missing piece there) Change-Id: Idc03ba965bfce2b94fef456b02ff6742194748f6 Reviewed-on: https://go-review.googlesource.com/34636 Reviewed-by: Ilya Tocar <ilya.tocar@intel.com> Run-TryBot: Ilya Tocar <ilya.tocar@intel.com> TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-12-01encoding/binary: document the new bool supportBrad Fitzpatrick
Updates #16856 Change-Id: I57af6b0c0d5ecdaf19cf6f969b05ec9ec03058f1 Reviewed-on: https://go-review.googlesource.com/33756 Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-09-28encoding/binary: add bool supportBlixt
This change adds support for decoding and encoding the bool type. The encoding is a single byte, with a zero value for false and a non-zero value for true. Closes #16856. Change-Id: I1d1114b320263691473bb100cad0f380e0204186 Reviewed-on: https://go-review.googlesource.com/28514 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
2016-04-15all: remove unnecessary type conversionsMatthew Dempsky
cmd and runtime were handled separately, and I'm intentionally skipped syscall. This is the rest of the standard library. CL generated mechanically with github.com/mdempsky/unconvert. Change-Id: I9e0eff886974dedc37adb93f602064b83e469122 Reviewed-on: https://go-review.googlesource.com/22104 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-31cmd/compile: extend prove pass to handle constant comparisonsKeith Randall
Find comparisons to constants and propagate that information down the dominator tree. Use it to resolve other constant comparisons on the same variable. So if we know x >= 7, then a x > 4 condition must return true. This change allows us to use "_ = b[7]" hints to eliminate bounds checks. Fixes #14900 Change-Id: Idbf230bd5b7da43de3ecb48706e21cf01bf812f7 Reviewed-on: https://go-review.googlesource.com/21008 Reviewed-by: Alexandru Moșoi <alexandru@mosoi.ro>
2016-03-21encoding/binary: fix bound checkAlexandru Moșoi
The inserted early bound checks cause the slice to expand beyond the original length of the slice. Change-Id: Ib38891605f4a9a12d3b9e2071a5f77640b083d2d Reviewed-on: https://go-review.googlesource.com/20981 Reviewed-by: Keith Randall <khr@golang.org> Reviewed-by: Minux Ma <minux@golang.org>
2016-03-18encoding/binary: don't assume b.N > 0Marcel van Lohuizen
Change-Id: I9e887a0b32baf0adc85fa9e4b85b319e8ef333e9 Reviewed-on: https://go-review.googlesource.com/20853 Reviewed-by: Russ Cox <rsc@golang.org>
2016-03-18encoding/binary: improve error messages for benchmarksMarcel van Lohuizen
Change-Id: I0f4b6752ecc8b4945ecfde627cdec13fc4bb6a69 Reviewed-on: https://go-review.googlesource.com/20850 Reviewed-by: Russ Cox <rsc@golang.org>
2016-03-17encoding/binary: remove bound checks from conversions.Alexandru Moșoi
* This the simplest solution I could came up with that doesn't required changing the compiler. * The bound checks become constants now so they are removed during opt phase. Updates #14808 Change-Id: If32c33d7ec08bb400321b465015d152f0a5d3001 Reviewed-on: https://go-review.googlesource.com/20654 Reviewed-by: Russ Cox <rsc@golang.org> Run-TryBot: Alexandru Moșoi <alexandru@mosoi.ro> TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-02all: single space after period.Brad Fitzpatrick
The tree's pretty inconsistent about single space vs double space after a period in documentation. Make it consistently a single space, per earlier decisions. This means contributors won't be confused by misleading precedence. This CL doesn't use go/doc to parse. It only addresses // comments. It was generated with: $ perl -i -npe 's,^(\s*// .+[a-z]\.) +([A-Z]),$1 $2,' $(git grep -l -E '^\s*//(.+\.) +([A-Z])') $ go test go/doc -update Change-Id: Iccdb99c37c797ef1f804a94b22ba5ee4b500c4f7 Reviewed-on: https://go-review.googlesource.com/20022 Reviewed-by: Rob Pike <r@golang.org> Reviewed-by: Dave Day <djd@golang.org> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-01all: make copyright headers consistent with one space after periodBrad Fitzpatrick
This is a subset of https://golang.org/cl/20022 with only the copyright header lines, so the next CL will be smaller and more reviewable. Go policy has been single space after periods in comments for some time. The copyright header template at: https://golang.org/doc/contribute.html#copyright also uses a single space. Make them all consistent. Change-Id: Icc26c6b8495c3820da6b171ca96a74701b4a01b0 Reviewed-on: https://go-review.googlesource.com/20111 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-09-30encoding/binary: document that Read returns io.EOF iff zero bytes are readJoe Tsai
Also add a unit test to lock this behavior into the API. Fixes #12016 Change-Id: Ib6ec6e7948f0705f3504ede9143b5dc4e790fc44 Reviewed-on: https://go-review.googlesource.com/15171 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-06-29encoding/binary: update protobuf documentation linkDmitry Savintsev
Updated the protobuf documentation URL (code.google.com deprecated) to avoid a redirect. Change-Id: I134f6e4a2bf2bba699942883bf6347bc61700bcb Reviewed-on: https://go-review.googlesource.com/11634 Reviewed-by: Russ Cox <rsc@golang.org>
2015-03-14encoding/binary: cull dead codeJosh Bleecher Snyder
Change-Id: I91f9b5280e08e005f5a891aaa249267c211d814b Reviewed-on: https://go-review.googlesource.com/7592 Reviewed-by: Minux Ma <minux@golang.org>
2014-12-22encoding/binary: check for unsigned integers in intDataSize.Stan Schwertly
intDataSize ignores unsigned integers, forcing reads/writes to miss the fast path. Fixes #8956 Change-Id: Ie79b565b037db3c469aa1dc6d0a8a5a9252d5f0a Reviewed-on: https://go-review.googlesource.com/1777 Reviewed-by: Russ Cox <rsc@golang.org>
2014-10-02encoding/binary: fix error messageRobert Griesemer
In the process, simplified internal sizeOf and dataSize functions. Minor positive impact on performance. Added test case. benchmark old ns/op new ns/op delta BenchmarkReadSlice1000Int32s 14006 14122 +0.83% BenchmarkReadStruct 2508 2447 -2.43% BenchmarkReadInts 921 928 +0.76% BenchmarkWriteInts 2086 2081 -0.24% BenchmarkWriteSlice1000Int32s 13440 13497 +0.42% BenchmarkPutUvarint32 28.5 26.3 -7.72% BenchmarkPutUvarint64 81.3 76.7 -5.66% benchmark old MB/s new MB/s speedup BenchmarkReadSlice1000Int32s 285.58 283.24 0.99x BenchmarkReadStruct 27.90 28.60 1.03x BenchmarkReadInts 32.57 32.31 0.99x BenchmarkWriteInts 14.38 14.41 1.00x BenchmarkWriteSlice1000Int32s 297.60 296.36 1.00x BenchmarkPutUvarint32 140.55 151.92 1.08x BenchmarkPutUvarint64 98.36 104.33 1.06x Fixes #6818. LGTM=r R=r CC=golang-codereviews https://golang.org/cl/149290045
2014-10-01encoding/binary: slightly better documentationRobert Griesemer
Fixes #7306. LGTM=r R=r CC=golang-codereviews https://golang.org/cl/153820044
2014-09-08build: move package sources from src/pkg to srcRuss Cox
Preparation was in CL 134570043. This CL contains only the effect of 'hg mv src/pkg/* src'. For more about the move, see golang.org/s/go14nopkg.