Benchmark is within the noise. I had to run this a dozen times
each before & after (on wall power, without a browser running)
before I could get halfway consistent numbers, and even then
they jumped all over the place, with the new one sometimes
being better. But these are the best of a dozen each.
Slowdown is expected anyway, since I imagine channels are
optimized more.
benchmark old ns/op new ns/op delta
BenchmarkCodeEncoder 26556987 27291072 +2.76%
BenchmarkEncoderEncode 1069 1071 +0.19%
benchmark old MB/s new MB/s speedup
BenchmarkCodeEncoder 73.07 71.10 0.97x
benchmark old allocs new allocs delta
BenchmarkEncoderEncode 2 2 0.00%
benchmark old bytes new bytes delta
BenchmarkEncoderEncode 221 221 0.00%
Update #4720
R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/37720047
sequences.
Use the same criteria for when to modify the tag type when
parsing a string in a sequence as when parsing a bare string
field.
Fixes#6726.
R=golang-dev, bradfitz, gobot, agl
CC=golang-dev
https://golang.org/cl/22460043
Don't make copies of keys while decoding, and don't use the
expensive strings.EqualFold when it's not necessary. Instead,
note in the existing field cache what algorithm to use to
check fold equality... most keys are just ASCII letters.
benchmark old ns/op new ns/op delta
BenchmarkCodeDecoder 137074314 103974418 -24.15%
benchmark old MB/s new MB/s speedup
BenchmarkCodeDecoder 14.16 18.66 1.32x
Update #6496
R=golang-dev, rsc, adg, r, mikioh.mikioh
CC=golang-dev
https://golang.org/cl/13894045
Also tweak the package document, putting in section headings and
adding a sentence about intended use.
Fixes#4925.
R=golang-dev, iant, adg, ugorji
CC=golang-dev
https://golang.org/cl/14519044
RawMessage is useful and mildly non-obvious.
Given the frequency with which RawMessage questions
show up on golang-nuts, and get answered with an example,
I suspect adding an example to the docs might help.
R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/14190044
newTypeEncoder (called once per type and then cached) was
looking at the first value seen of that type's addressability
and caching the encoder decision. If the first value seen was
addressable and a future one wasn't, it would panic.
Instead, introduce a new wrapper encoder type that checks
CanAddr at runtime.
Fixes#6458
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/13839045
Previously, fields of type chan or func caused an error.
Now we just treat them like unexported fields and ignore them.
This makes it easier to guarantee long-term compatibilty since
a substructure from another package cannot break gob
encoding by adding a func or chan field.
Fixes#6071
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/13693043
Flushing after every token negates the point of buffering. A different approach is required.
««« original CL description
encoding/xml: flush buffer after encoding token
R=rsc, bradfitz, adg
CC=golang-dev
https://golang.org/cl/13004046
»»»
R=golang-dev, adg, rsc
CC=golang-dev
https://golang.org/cl/13515043
Update #5000
Should reduce the flakiness a little. Malloc counting is important
to general testing but not to the build dashboard, which uses -short.
R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/12866047
Remove custom support for time.Time.
No new tests: the tests for the time.Time special case
now test the general case.
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/12751045
See golang.org/s/go12xml for design.
Repeat of CL 12603044, which was submitted accidentally
and then rolled back.
Fixes#2771.
Fixes#4169.
Fixes#5975.
Fixes#6125.
R=golang-dev
CC=golang-dev
https://golang.org/cl/12919043
fat fingers - did not intend to submit.
depends on the Unmarshaler CL anyway.
««« original CL description
encoding/xml: add, support Marshaler interface
See golang.org/s/go12xml for design.
Fixes#2771.
Fixes#4169.
Fixes#5975.
Fixes#6125.
R=golang-dev, iant, dan.kortschak
CC=golang-dev
https://golang.org/cl/12603044
»»»
TBR=golang-dev
CC=golang-dev
https://golang.org/cl/12918043
Again, it still allocates but the code is simple.
benchmark old ns/op new ns/op delta
BenchmarkReadSlice1000Int32s 35580 11465 -67.78%
benchmark old MB/s new MB/s speedup
BenchmarkReadSlice1000Int32s 112.42 348.86 3.10x
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/12694048
There are a few different places in the code that escape
possibly-problematic characters like < > and &.
This one was the only one missing &, so add it.
This means that if you Marshal a string, you get the
same answer you do if you Marshal a string and
pass it through the compactor. (Ironically, the
compaction makes the string longer.)
Because html/template invokes json.Marshal to
prepare escaped strings for JavaScript, this changes
the form of some of the escaped strings, but not
their meaning.
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/12708044
The old code was caching per-type struct field info. Instead,
cache type-specific encoding funcs, tailored for that
particular type to avoid unnecessary reflection at runtime.
Once the machine is built once, future encodings of that type
just run the func.
benchmark old ns/op new ns/op delta
BenchmarkCodeEncoder 48424939 36975320 -23.64%
benchmark old MB/s new MB/s speedup
BenchmarkCodeEncoder 40.07 52.48 1.31x
Additionally, the numbers seem stable now at ~52 MB/s, whereas
the numbers for the old code were all over the place: 11 MB/s,
40 MB/s, 13 MB/s, 39 MB/s, etc. In the benchmark above I compared
against the best I saw the old code do.
R=rsc, adg
CC=gobot, golang-dev, r
https://golang.org/cl/9129044
Simple approach. Still generates garbage, but not as much.
benchmark old ns/op new ns/op delta
BenchmarkWriteSlice1000Int32s 40260 18791 -53.33%
benchmark old MB/s new MB/s speedup
BenchmarkWriteSlice1000Int32s 99.35 212.87 2.14x
Fixes#2634.
R=golang-dev, crawshaw
CC=golang-dev
https://golang.org/cl/12680046
Original CL by rsc (11916045):
The motivation for disallowing them was RFC 4180 saying
"The last field in the record must not be followed by a comma."
I believe this is an admonition to CSV generators, not readers.
When reading, anything followed by a comma is not the last field.
Fixes#5892.
R=golang-dev, rsc, r
CC=golang-dev
https://golang.org/cl/12294043