<feed xmlns='http://www.w3.org/2005/Atom'>
<title>go/src/bytes/buffer.go, 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>2022-08-23T20:26:47Z</updated>
<entry>
<title>bytes: rely on utf8.AppendRune</title>
<updated>2022-08-23T20:26:47Z</updated>
<author>
<name>Joe Tsai</name>
<email>joetsai@digital-static.net</email>
</author>
<published>2022-06-16T00:03:27Z</published>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/go/commit/?id=70de482d17863e501be44450f8e60500a6f1b459'/>
<id>urn:sha1:70de482d17863e501be44450f8e60500a6f1b459</id>
<content type='text'>
This is both simpler and more performant.

WriteRune                                 23.9µs ± 1%   22.8µs ± 8%   -4.43%  (p=0.006 n=8+10)
ToUpper/longɐstringɐwithɐnonasciiⱯchars    573ns ± 4%    474ns ± 6%  -17.27%  (p=0.000 n=10+10)
ToUpper/ɐɐɐɐɐ                              236ns ± 6%    202ns ± 5%  -14.12%  (p=0.000 n=10+10)
ToUpper/a\u0080\U0010ffff                 98.8ns ± 6%   91.2ns ± 3%   -7.67%  (p=0.000 n=10+10)
ToLower/LONGⱯSTRINGⱯWITHⱯNONASCIIⱯCHARS    511ns ± 3%    409ns ± 4%  -20.02%  (p=0.000 n=10+10)
ToLower/ⱭⱭⱭⱭⱭ                              178ns ± 4%    173ns ± 2%   -2.76%  (p=0.005 n=10+10)
ToLower/A\u0080\U0010ffff                  100ns ± 3%     91ns ± 2%   -8.55%  (p=0.000 n=10+10)

Change-Id: I968ef194da2c115cbdcac2d3575c34c65e6a8a56
Reviewed-on: https://go-review.googlesource.com/c/go/+/412337
Reviewed-by: Ian Lance Taylor &lt;iant@google.com&gt;
Auto-Submit: Joseph Tsai &lt;joetsai@digital-static.net&gt;
TryBot-Result: Gopher Robot &lt;gobot@golang.org&gt;
Reviewed-by: David Chase &lt;drchase@google.com&gt;
Run-TryBot: Joseph Tsai &lt;joetsai@digital-static.net&gt;
</content>
</entry>
<entry>
<title>bytes: rely on runtime.growslice for growing</title>
<updated>2022-03-10T16:24:16Z</updated>
<author>
<name>Joe Tsai</name>
<email>joetsai@digital-static.net</email>
</author>
<published>2021-09-14T21:26:11Z</published>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/go/commit/?id=2d026a4ea5b28680c1ed7660f720c4cb028c5b35'/>
<id>urn:sha1:2d026a4ea5b28680c1ed7660f720c4cb028c5b35</id>
<content type='text'>
Rather than naively making a slice of capacity 2*c+n,
rely on the append(..., make(...)) pattern to allocate a
slice that aligns up to the closest size class.

Performance:
	name                          old time/op    new time/op    delta
	BufferWriteBlock/N4096       3.03µs ± 6%    2.04µs ± 6%  -32.60%  (p=0.000 n=10+10)
	BufferWriteBlock/N65536      47.8µs ± 6%    28.1µs ± 2%  -41.32%  (p=0.000 n=9+8)
	BufferWriteBlock/N1048576     844µs ± 7%     510µs ± 5%  -39.59%  (p=0.000 n=8+9)

	name                          old alloc/op   new alloc/op   delta
	BufferWriteBlock/N4096       12.3kB ± 0%     7.2kB ± 0%  -41.67%  (p=0.000 n=10+10)
	BufferWriteBlock/N65536       258kB ± 0%     130kB ± 0%  -49.60%  (p=0.000 n=10+10)
	BufferWriteBlock/N1048576    4.19MB ± 0%    2.10MB ± 0%  -49.98%  (p=0.000 n=10+8)

	name                          old allocs/op  new allocs/op  delta
	BufferWriteBlock/N4096         3.00 ± 0%      3.00 ± 0%     ~     (all equal)
	BufferWriteBlock/N65536        7.00 ± 0%      7.00 ± 0%     ~     (all equal)
	BufferWriteBlock/N1048576      11.0 ± 0%      11.0 ± 0%     ~     (all equal)

The performance is faster since the growth rate is capped at 2x,
while previously it could grow by amounts potentially much greater than 2x,
leading to significant amounts of memory waste and extra copying.

Credit goes to Martin Möhrmann for suggesting the
append(b, make([]T, n)...) pattern.

Fixes #42984
Updates #51462

Change-Id: I7b23f75dddbf53f8b8b93485bb1a1fff9649b96b
Reviewed-on: https://go-review.googlesource.com/c/go/+/349994
Trust: Joseph Tsai &lt;joetsai@digital-static.net&gt;
Trust: Josh Bleecher Snyder &lt;josharian@gmail.com&gt;
Reviewed-by: Bryan Mills &lt;bcmills@google.com&gt;
Reviewed-by: Ian Lance Taylor &lt;iant@golang.org&gt;
Reviewed-by: Josh Bleecher Snyder &lt;josharian@gmail.com&gt;
</content>
</entry>
<entry>
<title>bytes: correct tense in comment</title>
<updated>2021-03-15T17:37:09Z</updated>
<author>
<name>Ian Lance Taylor</name>
<email>iant@golang.org</email>
</author>
<published>2021-03-15T17:03:30Z</published>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/go/commit/?id=8ac6544564be04ed1c0bbf7831ad0f8ed1f067ed'/>
<id>urn:sha1:8ac6544564be04ed1c0bbf7831ad0f8ed1f067ed</id>
<content type='text'>
Undo incorrect change accidentally made in CL 299109.

Change-Id: Iba29827d0fbd3637c311cebc50c2f4ea437fc582
Reviewed-on: https://go-review.googlesource.com/c/go/+/301830
Trust: Ian Lance Taylor &lt;iant@golang.org&gt;
Reviewed-by: Tobias Klauser &lt;tobias.klauser@gmail.com&gt;
</content>
</entry>
<entry>
<title>all: remove duplicate words</title>
<updated>2021-03-13T11:56:59Z</updated>
<author>
<name>John Bampton</name>
<email>jbampton@gmail.com</email>
</author>
<published>2021-03-13T11:25:15Z</published>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/go/commit/?id=289d34a465d46e5c5c07034f5d54afbfda06f5b9'/>
<id>urn:sha1:289d34a465d46e5c5c07034f5d54afbfda06f5b9</id>
<content type='text'>
Change-Id: Ib0469232a2b69a869e58d5d24990ad74ac96ea56
GitHub-Last-Rev: eb38e049ee1e773392ff3747e1eb2af20dd50dcd
GitHub-Pull-Request: golang/go#44805
Reviewed-on: https://go-review.googlesource.com/c/go/+/299109
Trust: Emmanuel Odeke &lt;emmanuel@orijtech.com&gt;
Run-TryBot: Emmanuel Odeke &lt;emmanuel@orijtech.com&gt;
TryBot-Result: Go Bot &lt;gobot@golang.org&gt;
Reviewed-by: Bryan C. Mills &lt;bcmills@google.com&gt;
</content>
</entry>
<entry>
<title>bufio, bytes, strings: handle negative runes in WriteRune</title>
<updated>2021-02-24T04:01:25Z</updated>
<author>
<name>David Benjamin</name>
<email>davidben@google.com</email>
</author>
<published>2020-12-25T17:02:04Z</published>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/go/commit/?id=43652dc46f770253b3603f47165b1568b439b0b5'/>
<id>urn:sha1:43652dc46f770253b3603f47165b1568b439b0b5</id>
<content type='text'>
Updates #43254

Change-Id: I7d4bf3b99cc36ca2156af5bb01a1c595419d1d3c
Reviewed-on: https://go-review.googlesource.com/c/go/+/280492
Reviewed-by: Emmanuel Odeke &lt;emmanuel@orijtech.com&gt;
Reviewed-by: Rob Pike &lt;r@golang.org&gt;
Trust: Emmanuel Odeke &lt;emmanuel@orijtech.com&gt;
Run-TryBot: Emmanuel Odeke &lt;emmanuel@orijtech.com&gt;
TryBot-Result: Go Bot &lt;gobot@golang.org&gt;
</content>
</entry>
<entry>
<title>bytes: remove obsolete comment</title>
<updated>2019-05-28T02:52:39Z</updated>
<author>
<name>Maxim Eryomenko</name>
<email>moeryomenko@gmail.com</email>
</author>
<published>2019-05-28T02:45:21Z</published>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/go/commit/?id=0f897f916aa6734bb8d089400ea996ee461ae41f'/>
<id>urn:sha1:0f897f916aa6734bb8d089400ea996ee461ae41f</id>
<content type='text'>
Change-Id: Iec4348eb674c8c64497c82e5d7cd656736cfcebd
GitHub-Last-Rev: 462c323960be0ca1c126c051ab97f72949bdc2b6
GitHub-Pull-Request: golang/go#32225
Reviewed-on: https://go-review.googlesource.com/c/go/+/178797
Reviewed-by: Brad Fitzpatrick &lt;bradfitz@golang.org&gt;
</content>
</entry>
<entry>
<title>bytes: hoist error creation out of function</title>
<updated>2019-02-26T22:57:25Z</updated>
<author>
<name>Marcel van Lohuizen</name>
<email>mpvl@golang.org</email>
</author>
<published>2019-02-08T16:57:46Z</published>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/go/commit/?id=ef954a03eb9d4e8d19e1024db088095110e19a0b'/>
<id>urn:sha1:ef954a03eb9d4e8d19e1024db088095110e19a0b</id>
<content type='text'>
generating frame information in errors will cause this
function to no longer be inlined.

Updates #29934.

Change-Id: I1d7bc11707f1872d7315f627bfb9a12afa41e358
Reviewed-on: https://go-review.googlesource.com/c/161760
Run-TryBot: Marcel van Lohuizen &lt;mpvl@golang.org&gt;
TryBot-Result: Gobot Gobot &lt;gobot@golang.org&gt;
Reviewed-by: Russ Cox &lt;rsc@golang.org&gt;
Reviewed-by: Brad Fitzpatrick &lt;bradfitz@golang.org&gt;
</content>
</entry>
<entry>
<title>all: use "reports whether" consistently instead of "returns whether"</title>
<updated>2018-12-02T15:12:26Z</updated>
<author>
<name>Tobias Klauser</name>
<email>tklauser@distanz.ch</email>
</author>
<published>2018-11-22T10:46:44Z</published>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/go/commit/?id=9e277f7d554455e16ba3762541c53e9bfc1d8188'/>
<id>urn:sha1:9e277f7d554455e16ba3762541c53e9bfc1d8188</id>
<content type='text'>
Follow-up for CL 147037 and after Brad noticed the "returns whether"
pattern during the review of CL 150621.

Go documentation style for boolean funcs is to say:

    // Foo reports whether ...
    func Foo() bool

(rather than "returns whether")

Created with:

    $ perl -i -npe 's/returns whether/reports whether/' $(git grep -l "returns whether" | grep -v vendor)

Change-Id: I15fe9ff99180ad97750cd05a10eceafdb12dc0b4
Reviewed-on: https://go-review.googlesource.com/c/150918
Run-TryBot: Tobias Klauser &lt;tobias.klauser@gmail.com&gt;
Reviewed-by: Brad Fitzpatrick &lt;bradfitz@golang.org&gt;
</content>
</entry>
<entry>
<title>bytes: remove bootstrap array from Buffer</title>
<updated>2018-09-06T19:33:18Z</updated>
<author>
<name>Iskander Sharipov</name>
<email>iskander.sharipov@intel.com</email>
</author>
<published>2018-09-06T10:28:17Z</published>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/go/commit/?id=9c2be4c22d78cebc52458ba7298a470a3be0cdce'/>
<id>urn:sha1:9c2be4c22d78cebc52458ba7298a470a3be0cdce</id>
<content type='text'>
Rationale: small buffer optimization does not work and it has
made things slower since 2014. Until we can make it work,
we should prefer simpler code that also turns out to be more
efficient.

With this change, it's possible to use
NewBuffer(make([]byte, 0, bootstrapSize)) to get the desired
stack-allocated initial buffer since escape analysis can
prove the created slice to be non-escaping.

New implementation key points:

    - Zero value bytes.Buffer performs better than before
    - You can have a truly stack-allocated buffer, and it's not even limited to 64 bytes
    - The unsafe.Sizeof(bytes.Buffer{}) is reduced significantly
    - Empty writes don't cause allocations

Buffer benchmarks from bytes package:

    name                       old time/op    new time/op    delta
    ReadString-8                 9.20µs ± 1%    9.22µs ± 1%     ~     (p=0.148 n=10+10)
    WriteByte-8                  28.1µs ± 0%    26.2µs ± 0%   -6.78%  (p=0.000 n=10+10)
    WriteRune-8                  64.9µs ± 0%    65.0µs ± 0%   +0.16%  (p=0.000 n=10+10)
    BufferNotEmptyWriteRead-8     469µs ± 0%     461µs ± 0%   -1.76%  (p=0.000 n=9+10)
    BufferFullSmallReads-8        108µs ± 0%     108µs ± 0%   -0.21%  (p=0.000 n=10+10)

    name                       old speed      new speed      delta
    ReadString-8               3.56GB/s ± 1%  3.55GB/s ± 1%     ~     (p=0.165 n=10+10)
    WriteByte-8                 146MB/s ± 0%   156MB/s ± 0%   +7.26%  (p=0.000 n=9+10)
    WriteRune-8                 189MB/s ± 0%   189MB/s ± 0%   -0.16%  (p=0.000 n=10+10)

    name                       old alloc/op   new alloc/op   delta
    ReadString-8                 32.8kB ± 0%    32.8kB ± 0%     ~     (all equal)
    WriteByte-8                   0.00B          0.00B          ~     (all equal)
    WriteRune-8                   0.00B          0.00B          ~     (all equal)
    BufferNotEmptyWriteRead-8    4.72kB ± 0%    4.67kB ± 0%   -1.02%  (p=0.000 n=10+10)
    BufferFullSmallReads-8       3.44kB ± 0%    3.33kB ± 0%   -3.26%  (p=0.000 n=10+10)

    name                       old allocs/op  new allocs/op  delta
    ReadString-8                   1.00 ± 0%      1.00 ± 0%     ~     (all equal)
    WriteByte-8                    0.00           0.00          ~     (all equal)
    WriteRune-8                    0.00           0.00          ~     (all equal)
    BufferNotEmptyWriteRead-8      3.00 ± 0%      3.00 ± 0%     ~     (all equal)
    BufferFullSmallReads-8         3.00 ± 0%      2.00 ± 0%  -33.33%  (p=0.000 n=10+10)

The most notable thing in go1 benchmarks is reduced allocs in HTTPClientServer (-1 alloc):

    HTTPClientServer-8           64.0 ± 0%      63.0 ± 0%  -1.56%  (p=0.000 n=10+10)

For more explanations and benchmarks see the referenced issue.

Updates #7921

Change-Id: Ica0bf85e1b70fb4f5dc4f6a61045e2cf4ef72aa3
Reviewed-on: https://go-review.googlesource.com/133715
Reviewed-by: Martin Möhrmann &lt;moehrmann@google.com&gt;
Reviewed-by: Robert Griesemer &lt;gri@golang.org&gt;
Reviewed-by: Brad Fitzpatrick &lt;bradfitz@golang.org&gt;
</content>
</entry>
<entry>
<title>bytes: note that NewBuffer's initial size can change</title>
<updated>2018-08-29T22:36:49Z</updated>
<author>
<name>Alberto Donizetti</name>
<email>alb.donizetti@gmail.com</email>
</author>
<published>2018-08-29T14:46:19Z</published>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/go/commit/?id=c64006ab5d054396bd86c1c2a71931bb4ecce5ca'/>
<id>urn:sha1:c64006ab5d054396bd86c1c2a71931bb4ecce5ca</id>
<content type='text'>
bytes.NewBuffer's documentation says it can be used to set the initial
size of the buffer. The current wording is:

&gt; It can also be used to size the internal buffer for writing.

This may led users to believe that the buffer (its backing array) is
fixed in size and won't grow, which isn't true (subsequent Write calls
will expand the backing array as needed).

Change the doc to make it clearer that NewBuffer just sets the initial
size of the buffer.

Fixes #27242

Change-Id: I2a8cb5bee02ca2c1657ef59e2cf1434c7a9bd397
Reviewed-on: https://go-review.googlesource.com/132035
Reviewed-by: Dominik Honnef &lt;dominik@honnef.co&gt;
Reviewed-by: Ian Lance Taylor &lt;iant@golang.org&gt;
</content>
</entry>
</feed>
