<feed xmlns='http://www.w3.org/2005/Atom'>
<title>go/src/encoding, branch json-isValidNumber</title>
<subtitle>Fork of Go programming language with my patches.</subtitle>
<id>http://git.kilabit.info/go/atom?h=json-isValidNumber</id>
<link rel='self' href='http://git.kilabit.info/go/atom?h=json-isValidNumber'/>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/go/'/>
<updated>2023-02-18T09:15:58Z</updated>
<entry>
<title>encoding/json: optimize isValidNumber function</title>
<updated>2023-02-18T09:15:58Z</updated>
<author>
<name>Shulhan</name>
<email>m.shulhan@gmail.com</email>
</author>
<published>2022-08-26T14:48:21Z</published>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/go/commit/?id=02b962186be4ed9597df5fc526ef85b2e66cf55b'/>
<id>urn:sha1:02b962186be4ed9597df5fc526ef85b2e66cf55b</id>
<content type='text'>
We use an index instead of reslicing the string because reslicing a string
updates both the data and length fields instead of just the one index
variable.

Benchmark result,

name             old time/op    new time/op    delta
NumberIsValid-8  19.0ns ± 0%    14.5ns ± 1%  -23.70%  (p=0.008 n=5+5)

name             old alloc/op   new alloc/op   delta
NumberIsValid-8   0.00B          0.00B          ~     (all equal)

name             old allocs/op  new allocs/op  delta
NumberIsValid-8    0.00           0.00          ~     (all equal)

Change-Id: I4698c5db134998f83ff47fb3add6a04ba6ec3aa0
</content>
</entry>
<entry>
<title>src: rename unexported errors by adding prefix err</title>
<updated>2023-02-16T23:09:19Z</updated>
<author>
<name>Oleksandr Redko</name>
<email>oleksandr.red+github@gmail.com</email>
</author>
<published>2023-02-12T13:37:00Z</published>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/go/commit/?id=3ad6393f8676b1b408673bf40b8a876f29561eef'/>
<id>urn:sha1:3ad6393f8676b1b408673bf40b8a876f29561eef</id>
<content type='text'>
By convention, use `err` as prefix for variables of type `error`.

Change-Id: I9401d5d47e994a27be245b2c8b1edd55cdd52db1
Reviewed-on: https://go-review.googlesource.com/c/go/+/467536
Auto-Submit: Ian Lance Taylor &lt;iant@google.com&gt;
Reviewed-by: Robert Griesemer &lt;gri@google.com&gt;
TryBot-Result: Gopher Robot &lt;gobot@golang.org&gt;
Reviewed-by: Ian Lance Taylor &lt;iant@google.com&gt;
Run-TryBot: Ian Lance Taylor &lt;iant@google.com&gt;
</content>
</entry>
<entry>
<title>encoding/hex: fix Decode output check regression</title>
<updated>2023-02-07T15:37:55Z</updated>
<author>
<name>Joe Tsai</name>
<email>joetsai@digital-static.net</email>
</author>
<published>2023-02-06T22:48:19Z</published>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/go/commit/?id=f02cdba16398cee70a69262a55eb357dac6f81df'/>
<id>urn:sha1:f02cdba16398cee70a69262a55eb357dac6f81df</id>
<content type='text'>
CL 461958 fixed a potential panic,
but also introduced an observable regression where
invalid input could be detected before the panic occurs.
Adjust the check to preserve prior behavior,
while also preventing the panic.

Change-Id: I52819f88a6a64883fbc9fd512697c38c29ca0ccd
Reviewed-on: https://go-review.googlesource.com/c/go/+/465855
Auto-Submit: Joseph Tsai &lt;joetsai@digital-static.net&gt;
TryBot-Result: Gopher Robot &lt;gobot@golang.org&gt;
Reviewed-by: Bryan Mills &lt;bcmills@google.com&gt;
Run-TryBot: Joseph Tsai &lt;joetsai@digital-static.net&gt;
Reviewed-by: Ian Lance Taylor &lt;iant@google.com&gt;
</content>
</entry>
<entry>
<title>encoding/xml: allow overriding by empty namespace</title>
<updated>2023-01-31T18:23:50Z</updated>
<author>
<name>Constantin Konstantinidis</name>
<email>constantinkonstantinidis@gmail.com</email>
</author>
<published>2022-07-05T05:46:07Z</published>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/go/commit/?id=dfd2ddd6717acb16b43ecde5150a7d8916ac5484'/>
<id>urn:sha1:dfd2ddd6717acb16b43ecde5150a7d8916ac5484</id>
<content type='text'>
The namespace defined by xmlns="value" can be overridden in every included tag
by the empty namespace xmlns="" without a prefix.

Method to calculate indent of XML handles depth of tag and its associated namespace is
still active even when no indent is required.

An XMLName field in a struct means that namespace must be enforced even if empty.
This occurs only on an inner tag as an override of any non-empty namespace of its outer tag.
An attribute is added to have the required namespace display.

Fixes #7113

Change-Id: I57f2308e98c66f04108ab136d350bdc3a6091e98
Reviewed-on: https://go-review.googlesource.com/c/go/+/108796
TryBot-Result: Gopher Robot &lt;gobot@golang.org&gt;
Reviewed-by: Michael Knyszek &lt;mknyszek@google.com&gt;
Run-TryBot: Ian Lance Taylor &lt;iant@golang.org&gt;
Run-TryBot: Ian Lance Taylor &lt;iant@google.com&gt;
Reviewed-by: Ian Lance Taylor &lt;iant@google.com&gt;
Auto-Submit: Ian Lance Taylor &lt;iant@google.com&gt;
</content>
</entry>
<entry>
<title>encoding/binary: add String and GoString method to nativeEndian</title>
<updated>2023-01-30T18:51:09Z</updated>
<author>
<name>cuiweixie</name>
<email>cuiweixie@gmail.com</email>
</author>
<published>2023-01-29T08:42:17Z</published>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/go/commit/?id=848d658c45b185efb6742e51ba261cbba801b6ee'/>
<id>urn:sha1:848d658c45b185efb6742e51ba261cbba801b6ee</id>
<content type='text'>
Updates #57237

Change-Id: Ib626610130cae9c1d1aff5dd2a5035ffde0e127f
Reviewed-on: https://go-review.googlesource.com/c/go/+/463985
Reviewed-by: Ian Lance Taylor &lt;iant@google.com&gt;
Run-TryBot: xie cui &lt;523516579@qq.com&gt;
TryBot-Result: Gopher Robot &lt;gobot@golang.org&gt;
Run-TryBot: Ian Lance Taylor &lt;iant@google.com&gt;
Auto-Submit: Ian Lance Taylor &lt;iant@google.com&gt;
Reviewed-by: Michael Knyszek &lt;mknyszek@google.com&gt;
</content>
</entry>
<entry>
<title>all: fix problematic comments</title>
<updated>2023-01-30T18:10:36Z</updated>
<author>
<name>cui fliter</name>
<email>imcusg@gmail.com</email>
</author>
<published>2023-01-29T06:40:22Z</published>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/go/commit/?id=dbfdc446fe70a3639ba00eb3d9141ba10783d7cf'/>
<id>urn:sha1:dbfdc446fe70a3639ba00eb3d9141ba10783d7cf</id>
<content type='text'>
Change-Id: If092ae7c72b66f172ae32fa6c7294a7ac250362e
Reviewed-on: https://go-review.googlesource.com/c/go/+/463995
Reviewed-by: Cherry Mui &lt;cherryyz@google.com&gt;
TryBot-Result: Gopher Robot &lt;gobot@golang.org&gt;
Reviewed-by: Than McIntosh &lt;thanm@google.com&gt;
Run-TryBot: Than McIntosh &lt;thanm@google.com&gt;
</content>
</entry>
<entry>
<title>encoding/binary: add var NativeEndian</title>
<updated>2023-01-27T18:17:20Z</updated>
<author>
<name>cuiweixie</name>
<email>cuiweixie@gmail.com</email>
</author>
<published>2023-01-25T03:22:29Z</published>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/go/commit/?id=4b3726e99bec62e4a8b8e9cecc478b51ce0d4636'/>
<id>urn:sha1:4b3726e99bec62e4a8b8e9cecc478b51ce0d4636</id>
<content type='text'>
Updates #57237

Change-Id: I149c8b7eeac91b87b5810250f96d48ca87135807
Reviewed-on: https://go-review.googlesource.com/c/go/+/463218
Reviewed-by: Ian Lance Taylor &lt;iant@google.com&gt;
Reviewed-by: Dmitri Shuralyov &lt;dmitshur@google.com&gt;
TryBot-Result: Gopher Robot &lt;gobot@golang.org&gt;
Run-TryBot: Ian Lance Taylor &lt;iant@google.com&gt;
Run-TryBot: xie cui &lt;523516579@qq.com&gt;
Auto-Submit: Ian Lance Taylor &lt;iant@google.com&gt;
</content>
</entry>
<entry>
<title>hex: fix panic in Decode when len(src) &gt; 2*len(dst)</title>
<updated>2023-01-27T15:28:30Z</updated>
<author>
<name>Benjamin Prosnitz</name>
<email>bprosnitz@gmail.com</email>
</author>
<published>2023-01-13T16:54:35Z</published>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/go/commit/?id=a106defddac515db4d70e1cad162b88dd026deee'/>
<id>urn:sha1:a106defddac515db4d70e1cad162b88dd026deee</id>
<content type='text'>
hex.Decode never checks the length of dst and triggers a panic
if there are insufficient bytes in the slice.

There isn't document on what the behavior *should* be in this case.
Two possibilities:
1. Error dst has insufficient space (as done in this change)
2. Reduce the length of the decode to min(dst, src)

Option 1 was chosen because it seems the least surprising or
subtle.

Change-Id: I3bf029e3d928202de716830434285e3c165f26dd
Reviewed-on: https://go-review.googlesource.com/c/go/+/461958
Reviewed-by: Ian Lance Taylor &lt;iant@google.com&gt;
Auto-Submit: Ian Lance Taylor &lt;iant@google.com&gt;
Reviewed-by: Bryan Mills &lt;bcmills@google.com&gt;
Run-TryBot: Ian Lance Taylor &lt;iant@google.com&gt;
TryBot-Result: Gopher Robot &lt;gobot@golang.org&gt;
Reviewed-by: Benjamin Prosnitz &lt;bprosnitz@gmail.com&gt;
Run-TryBot: Ian Lance Taylor &lt;iant@golang.org&gt;
</content>
</entry>
<entry>
<title>encoding/gob: slightly simplify init code</title>
<updated>2023-01-24T20:07:49Z</updated>
<author>
<name>Daniel Martí</name>
<email>mvdan@mvdan.cc</email>
</author>
<published>2023-01-20T21:53:34Z</published>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/go/commit/?id=43f9b826c322d5541ca0260f8b0c9b71db0f7ec8'/>
<id>urn:sha1:43f9b826c322d5541ca0260f8b0c9b71db0f7ec8</id>
<content type='text'>
https://go.dev/cl/460543 stopped using the "expect" parameter in
bootstrapType, but we forgot to actually remove it.

While here, staticcheck correctly points out that we can use the copy
builtin to fill builtinIdToTypeSlice, now that it and idToType are an
array and slice respectively.

Change-Id: I48078415ab9bdd5633cf41f33ab4dc78eb30b48a
Reviewed-on: https://go-review.googlesource.com/c/go/+/462301
Run-TryBot: Daniel Martí &lt;mvdan@mvdan.cc&gt;
Run-TryBot: Rob Pike &lt;r@golang.org&gt;
Reviewed-by: Rob Pike &lt;r@golang.org&gt;
Reviewed-by: Ian Lance Taylor &lt;iant@google.com&gt;
TryBot-Result: Gopher Robot &lt;gobot@golang.org&gt;
Reviewed-by: Matthew Dempsky &lt;mdempsky@google.com&gt;
</content>
</entry>
<entry>
<title>encoding/gob: shave off some init time cost</title>
<updated>2023-01-20T09:34:41Z</updated>
<author>
<name>Daniel Martí</name>
<email>mvdan@mvdan.cc</email>
</author>
<published>2023-01-08T20:03:33Z</published>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/go/commit/?id=8259ac4986db5ce6dbdd9883b0bbd1402bfe7532'/>
<id>urn:sha1:8259ac4986db5ce6dbdd9883b0bbd1402bfe7532</id>
<content type='text'>
Avoid unnecessary allocations when calling reflect.TypeOf;
we can use nil pointers, which fit into an interface without allocating.
This saves about 1% of CPU time.

The builtin types are limited to typeIds between 0 and firstUserId,
and since firstUserId is 64, builtinIdToType does not need to be a map.
We can simply use an array of length firstUserId, which is simpler.
This saves about 1% of CPU time.

idToType is similar to firstUserId in that it is a map keyed by typeIds.
The difference is that it can grow with the user's types.
However, each added type gets the next available typeId,
meaning that we can use a growing slice, similar to the case above.
nextId then becomes the current length of the slice.
This saves about 1% of CPU time.

typeInfoMap is stored globally as an atomic.Value,
where each modification loads the map, makes a whole copy,
adds the new element, and stores the modified copy.
This is perfectly fine when the user registers types,
as that can happen concurrently and at any point in the future.

However, during init time, we sequentially register many types,
and the overhead of copying maps adds up noticeably.
During init time, use a regular global map instead,
which gets replaced by the atomic.Value when our init work is done.
This saves about 2% of CPU time.

Finally, avoid calling checkId in bootstrapType;
we have just called setTypeId, whose logic for getting nextId is simple,
so the extra check doesn't gain us much.
This saves about 1% of CPU time.

Using benchinit, which transforms GODEBUG=inittrace=1 data into Go
benchmark compatible output, results in a nice improvement:

	name         old time/op    new time/op    delta
	EncodingGob     175µs ± 0%     162µs ± 0%  -7.45%  (p=0.016 n=5+4)

	name         old alloc/op   new alloc/op   delta
	EncodingGob    39.0kB ± 0%    36.1kB ± 0%  -7.35%  (p=0.016 n=5+4)

	name         old allocs/op  new allocs/op  delta
	EncodingGob       588 ± 0%       558 ± 0%  -5.10%  (p=0.000 n=5+4)

Updates #26775.

Change-Id: I28618e8b96ef440480e666ef2cd5c4a9a332ef21
Reviewed-on: https://go-review.googlesource.com/c/go/+/460543
Reviewed-by: Carlos Amedee &lt;carlos@golang.org&gt;
Reviewed-by: Cherry Mui &lt;cherryyz@google.com&gt;
Reviewed-by: Rob Pike &lt;r@golang.org&gt;
Run-TryBot: Rob Pike &lt;r@golang.org&gt;
TryBot-Result: Gopher Robot &lt;gobot@golang.org&gt;
</content>
</entry>
</feed>
