aboutsummaryrefslogtreecommitdiff
path: root/src/bufio
AgeCommit message (Collapse)Author
18 hoursbufio: realign struct ScannerShulhan
This reduce the Scanner allocation size from 112 to 72 bytes.
18 hoursbufio: realign struct ReaderShulhan
This reduce the Reader allocation size from 72 to 40 bytes and Writer allocation size from 64 to 40 bytes.
2026-02-06bufio: fix doc link to Reset methodMichal Bohuslávek
On https://pkg.go.dev/bufio#Reader, the reference to the Reset method is rendered as [Reset]. Fix it by referring to the method via its type. Change-Id: I4256ca80ebef7b850e6a97b96503dd7178cb361b Reviewed-on: https://go-review.googlesource.com/c/go/+/736320 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Daniel Morsing <daniel.morsing@gmail.com> Auto-Submit: Michael Knyszek <mknyszek@google.com> Reviewed-by: Robert Griesemer <gri@google.com> Reviewed-by: Michael Knyszek <mknyszek@google.com>
2025-09-03unicode/utf8: make DecodeRune{,InString} inlineableJulien Cretel
This change makes the fast path for ASCII characters inlineable in DecodeRune and DecodeRuneInString and removes most instances of manual inlining at call sites. Here are some benchmark results (no change to allocations): goos: darwin goarch: amd64 pkg: unicode/utf8 cpu: Intel(R) Core(TM) i7-6700HQ CPU @ 2.60GHz │ old │ new │ │ sec/op │ sec/op vs base │ DecodeASCIIRune-8 2.4545n ± 2% 0.6253n ± 2% -74.52% (p=0.000 n=20) DecodeJapaneseRune-8 3.988n ± 1% 4.023n ± 1% +0.86% (p=0.050 n=20) DecodeASCIIRuneInString-8 2.4675n ± 1% 0.6264n ± 2% -74.61% (p=0.000 n=20) DecodeJapaneseRuneInString-8 3.992n ± 1% 4.001n ± 1% ~ (p=0.625 n=20) geomean 3.134n 1.585n -49.43% Note: when #61502 gets resolved, DecodeRune and DecodeRuneInString should be reverted to their idiomatic implementations. Fixes #31666 Updates #48195 Change-Id: I4be25c4f52417dc28b3a7bd72f1b04018470f39d GitHub-Last-Rev: 2e352a0045027e059be79cdb60241b5cf35fec71 GitHub-Pull-Request: golang/go#75181 Reviewed-on: https://go-review.googlesource.com/c/go/+/699675 Reviewed-by: Sean Liao <sean@liao.dev> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Michael Pratt <mpratt@google.com>
2025-05-21bufio: update buffer documentationLokesh Kumar
Fixes #73778 Change-Id: If6d87a92786c9b0ee2bd790b57937919afe0fc5c GitHub-Last-Rev: 4b4c7595d5779a127b01a5d71adca91cb5aa6c05 GitHub-Pull-Request: golang/go#73804 Reviewed-on: https://go-review.googlesource.com/c/go/+/674695 Auto-Submit: Alan Donovan <adonovan@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Alan Donovan <adonovan@google.com>
2025-02-07bufio: skip network test if unixpacket socket not supportedIan Lance Taylor
Change-Id: I03434fdc4916fc8d195de2617edc28ec4b66a172 Reviewed-on: https://go-review.googlesource.com/c/go/+/647535 Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Damien Neil <dneil@google.com>
2025-02-06bufio: don't do empty Write at start of WriteToIan Lance Taylor
The empty Write will cause the wrong thing to happen when using io.Copy to copy to a package-based stream. Fixes #71424 Change-Id: I046a27539447182692ac76a8bdd422327345dd8d Reviewed-on: https://go-review.googlesource.com/c/go/+/644535 Reviewed-by: Keith Randall <khr@golang.org> Reviewed-by: Michael Knyszek <mknyszek@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Keith Randall <khr@google.com> Auto-Submit: Ian Lance Taylor <iant@golang.org> Reviewed-by: Mauri de Souza Meneguzzo <mauri870@gmail.com> Reviewed-by: Damien Neil <dneil@google.com>
2024-12-09bufio: make the description of Peek's behavior betterPetr Osetrov
Previously, based on the description, it was not obvious that Peek could change the buffer. It may have been mistakenly assumed that Peek would always return an error if n is greater than b.Buffered(). Change-Id: I095006dd2ba1c2138bb193396cb24e2dda42d771 GitHub-Last-Rev: 9d48f8ac81f46d5b8f4a1885af28cbccd1747c3b GitHub-Pull-Request: golang/go#70712 Reviewed-on: https://go-review.googlesource.com/c/go/+/634175 Reviewed-by: Carlos Amedee <carlos@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Jorropo <jorropo.pgm@gmail.com>
2024-12-04bufio: document Reader must be created with New functionsSean Liao
Fixes #37347 Change-Id: Id642dbe7e52933f8d6cf7116c3c27ddb74efba9d Reviewed-on: https://go-review.googlesource.com/c/go/+/633315 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Robert Griesemer <gri@google.com> Reviewed-by: Michael Knyszek <mknyszek@google.com>
2024-11-01bufio: add example for ReadFrom and remove unused codecuishuang
Change-Id: Ia4fbb436ca573b1820f2b4d06d2332f588334768 Reviewed-on: https://go-review.googlesource.com/c/go/+/624357 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Carlos Amedee <carlos@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com>
2024-10-28all: skip and fix various tests with -asan and -msanMichael Anthony Knyszek
First, skip all the allocation count tests. In some cases this aligns with existing skips for -race, but in others we've got new issues. These are debug modes, so some performance loss is expected, and this is clearly no worse than today where the tests fail. Next, skip internal linking and static linking tests for msan and asan. With asan we get an explicit failure that neither are supported by the C and/or Go compilers. With msan, we only get the Go compiler telling us internal linking is unavailable. With static linking, we segfault instead. Filed #70080 to track that. Next, skip some malloc tests with asan that don't quite work because of the redzone. This is because of some sizeclass assumptions that get broken with the redzone and the fact that the tiny allocator is effectively disabled (again, due to the redzone). Next, skip some runtime/pprof tests with asan, because of extra allocations. Next, skip some malloc tests with asan that also fail because of extra allocations. Next, fix up memstats accounting for arenas when asan is enabled. There is a bug where more is added to the stats than subtracted. This also simplifies the accounting a little. Next, skip race tests with msan or asan enabled; they're mutually incompatible. Fixes #70054. Fixes #64256. Fixes #64257. For #70079. For #70080. Change-Id: I99c02a0b9d621e44f1f918b307aa4a4944c3ec60 Cq-Include-Trybots: luci.golang.try:gotip-linux-amd64-asan-clang15,gotip-linux-amd64-msan-clang15 Reviewed-on: https://go-review.googlesource.com/c/go/+/622855 Reviewed-by: Cherry Mui <cherryyz@google.com> TryBot-Bypass: Michael Knyszek <mknyszek@google.com>
2024-09-03all: omit unnecessary 0 in slice expressionnlwkobe30
All changes are related to the code, except for the comments in src/regexp/syntax/parse.go and src/slices/slices.go. Change-Id: I73c5d3c54099749b62210aa7f3182c5eb84bb6a6 GitHub-Last-Rev: 794aa9b0539811d00e1cd42be1e8d9fe9afe0281 GitHub-Pull-Request: golang/go#69170 Reviewed-on: https://go-review.googlesource.com/c/go/+/609678 Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com>
2023-10-23bufio: allow terminating Scanner early cleanly without a final token or an errorfavonia
Fixes #56381 Change-Id: I95cd603831a7032d764ab312869fe9fb05848a4b Reviewed-on: https://go-review.googlesource.com/c/go/+/498117 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Benny Siegert <bsiegert@gmail.com>
2023-10-14bufio: link "too large to fit" to Scanner.BufferIan Lance Taylor
Change-Id: Id0a4f5716da98008eec10eee05b74fc2a155ba3c Reviewed-on: https://go-review.googlesource.com/c/go/+/535216 Reviewed-by: Mauri de Souza Meneguzzo <mauri870@gmail.com> Auto-Submit: Ian Lance Taylor <iant@golang.org> Reviewed-by: Rob Pike <r@golang.org> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2023-10-12bufio: add available godoc linkcui fliter
Change-Id: Id32bae57c9fcc2074f82089ba9c69be9a601f128 Reviewed-on: https://go-review.googlesource.com/c/go/+/534758 Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Run-TryBot: shuang cui <imcusg@gmail.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2023-10-04bufio: use max/min funcqiulaidongfeng
Change-Id: I52875f8dd4bbdc9296ba8e4f801356047ee14e62 GitHub-Last-Rev: dfb2a343e60f0994a5741e1b4534e464a80ba2ef GitHub-Pull-Request: golang/go#63344 Reviewed-on: https://go-review.googlesource.com/c/go/+/532216 Reviewed-by: Robert Griesemer <gri@google.com> Reviewed-by: Keith Randall <khr@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Keith Randall <khr@google.com> Run-TryBot: Robert Griesemer <gri@google.com> Auto-Submit: Robert Griesemer <gri@google.com>
2023-09-22all: clean unnecessary casts for test filesJes Cok
This is a follow up of CL 528696. Change-Id: I5b71eabedb12567c4b1b36f7182a3d2b0ed662a5 GitHub-Last-Rev: acaf3ac11c38042ad27b99e1c70a3c9f1a554a15 GitHub-Pull-Request: golang/go#62713 Reviewed-on: https://go-review.googlesource.com/c/go/+/529197 Reviewed-by: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Matthew Dempsky <mdempsky@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2023-08-16bufio: clarify the maximum token sizeqiulaidongfeng
Fixes #43183. Change-Id: I50d99ef8ed513bba47166a25ea5c7c80cd8bd799 GitHub-Last-Rev: 684d70e9a3dbc0ce280e1112105d666cd5754e9f GitHub-Pull-Request: golang/go#61979 Reviewed-on: https://go-review.googlesource.com/c/go/+/518860 Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Auto-Submit: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Run-TryBot: Ian Lance Taylor <iant@google.com> Reviewed-by: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Rob Pike <r@golang.org>
2023-02-10bufio: permit r.Reset(r) without infinite recursionIan Lance Taylor
This can happen in reasonable code because NewReader(r) can return r, if r is already a Reader. Similarly for Writer. Fixes #58423 Change-Id: Iff9d9265410bee68fbaeb7175369847bd737eb2c Reviewed-on: https://go-review.googlesource.com/c/go/+/466815 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Bryan Mills <bcmills@google.com> Run-TryBot: Ian Lance Taylor <iant@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Run-TryBot: Ian Lance Taylor <iant@golang.org>
2022-09-29bufio: use strings.Buildercuiweixie
Change-Id: Ia8d6cea75b32c8839837c1bb1e13cde9b236abdd Reviewed-on: https://go-review.googlesource.com/c/go/+/435939 Run-TryBot: xie cui <523516579@qq.com> Reviewed-by: Robert Griesemer <gri@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org>
2022-09-27bufio: use bytes.Clonecuiweixie
Change-Id: Ic21d979da8be1a6047b9bcd65b5ee71ca2ef7548 Reviewed-on: https://go-review.googlesource.com/c/go/+/435278 Reviewed-by: Robert Griesemer <gri@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Run-TryBot: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com>
2022-09-06bufio: use strings.Buildercuiweixie
Change-Id: Ief82f12a5c48c46165c28140997d5fc83700c758 Reviewed-on: https://go-review.googlesource.com/c/go/+/428256 Run-TryBot: Ian Lance Taylor <iant@google.com> Reviewed-by: Robert Griesemer <gri@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Ian Lance Taylor <iant@google.com>
2022-05-02bufio: clarify io.EOF behavior of Reader.ReadIan Lance Taylor
Fixes #52577 Change-Id: Idaff2604979f9a9c1c7d3140c8a5d218fcd27a56 Reviewed-on: https://go-review.googlesource.com/c/go/+/403594 Reviewed-by: Joseph Tsai <joetsai@digital-static.net> Reviewed-by: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Bryan Mills <bcmills@google.com> Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Ian Lance Taylor <iant@google.com>
2022-04-21bufio: implement large write forwarding in Writer.WriteStringCarlo Alberto Ferraris
Currently bufio.Writer implements forwarding to the underlying Writer for large writes via Write, but it does not do the same for large writes via WriteString. If the underlying Writer is also a StringWriter, use the same "large writes" logic also in WriteString while taking care to only check once per call to WriteString whether the underlying Writer implements StringWriter. Change-Id: Id81901c07b035936816b9e41b1f5688e699ee8e9 Reviewed-on: https://go-review.googlesource.com/c/go/+/380074 Reviewed-by: Ian Lance Taylor <iant@google.com> Run-TryBot: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2022-04-01all: remove trailing blank doc comment linesRuss Cox
A future change to gofmt will rewrite // Doc comment. // func f() to // Doc comment. func f() Apply that change preemptively to all doc comments. For #51082. Change-Id: I4023e16cfb0729b64a8590f071cd92f17343081d Reviewed-on: https://go-review.googlesource.com/c/go/+/384259 Trust: Russ Cox <rsc@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org>
2021-12-15all: fix typo in commentichxxx
Remove duplicate 'the' Change-Id: I3ed81c8d9c488662387e45580a3bcd462448ba44 GitHub-Last-Rev: 86443993b9b58c6fce4e09e283604c32ccc44cec GitHub-Pull-Request: golang/go#50017 Reviewed-on: https://go-review.googlesource.com/c/go/+/372394 Reviewed-by: Robert Griesemer <gri@golang.org> Run-TryBot: Robert Griesemer <gri@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-11-26bufio: mention that panic at slicing means underlying reader is brokenKeith Randall
Fixes #49795 Change-Id: I2b4fd14f0ed36b643522559bebf5ce52b1d7b304 Reviewed-on: https://go-review.googlesource.com/c/go/+/367214 Trust: Keith Randall <khr@golang.org> Run-TryBot: Keith Randall <khr@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-11-09bufio: document that NewWriter can return its argumentIan Lance Taylor
Fixes #49446 Change-Id: Ib0b53a7dd5d567a2dd0bdf29f53d276587b60afb Reviewed-on: https://go-review.googlesource.com/c/go/+/361921 Trust: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
2021-11-05bufio: fix typo in commentlgbgbl
Change-Id: I6074334bc73ee1773fc83d049142ad764e39e5a9 GitHub-Last-Rev: 6a8789318ab132a169a89be807394af55c855ce9 GitHub-Pull-Request: golang/go#49373 Reviewed-on: https://go-review.googlesource.com/c/go/+/361413 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-10-18bufio: use underlying ReadFrom even when data is bufferedDamien Neil
When (*bufio.Writer).ReadFrom is called with a partially filled buffer, fill out and flush the buffer and then call the underlying writer's ReadFrom method if present. Fixes #44815. Change-Id: I15b3ef0746d0d60fd62041189a9b9df11254dd29 Reviewed-on: https://go-review.googlesource.com/c/go/+/340530 Trust: Damien Neil <dneil@google.com> Run-TryBot: Damien Neil <dneil@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-10-01bufio: reject UnreadByte or UnreadRune after a Discard or WriteToBryan C. Mills
Discard is not really a read operation, and in theory it could Seek the underlying Reader without actually reading anything, so an UnreadByte following a Discard is disallowed. Similarly, although WriteTo usually does end up calling Read on the underlying buffer, if the underlying Reader implements io.WriterTo it may instead terminate in a call to WriteTo, without ever buffering or even seeing the last byte written. (It is conceptually read-like, but not strictly “a read operation”.) Fixes #48446 Change-Id: Ide6f2b157332b423486810399f66140c914144e5 Reviewed-on: https://go-review.googlesource.com/c/go/+/351810 Trust: Bryan C. Mills <bcmills@google.com> Trust: Joe Tsai <joetsai@digital-static.net> Reviewed-by: Joe Tsai <joetsai@digital-static.net>
2021-09-12bufio: add Writer.AvailableBufferJoe Tsai
This adds a new Writer.AvailableBuffer method that returns an empty buffer with a possibly non-empty capacity for use with append-like APIs. The typical usage pattern is something like: b := bw.AvailableBuffer() b = appendValue(b, v) bw.Write(b) It allows logic combining append-like APIs with bufio.Writer to avoid needing to allocate and manage buffers themselves and allows the append-like APIs to directly write into the buffer for a bufio.Writer. Fixes #47527 Change-Id: I9cd169f3f8e8c7cd40818caf3daf1944c826fc66 Reviewed-on: https://go-review.googlesource.com/c/go/+/345569 Trust: Joe Tsai <joetsai@digital-static.net> Run-TryBot: Joe Tsai <joetsai@digital-static.net> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-09-11bufio: make Reader.Reset and Writer.Reset work on the zero valueJoe Tsai
For batch allocation reasons, it would be useful to nest a bufio.Reader or bufio.Writer in a struct as a value, rather than a pointer. When the Reset method is called, have it use the default buffer size if the buffer is nil. Fixes #45374 Change-Id: I80df18a13575431428a42ed150a1579de1282637 Reviewed-on: https://go-review.googlesource.com/c/go/+/345570 Trust: Joe Tsai <joetsai@digital-static.net> Run-TryBot: Joe Tsai <joetsai@digital-static.net> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-04-30bufio: mention ErrFinalToken in SplitFunc documentationMatt Harden
It is documented elsewhere in the package documentation but this additional mention of it will hopefully reduce confusion. Fixes #44261 Change-Id: I4e9d8f4564ebb7fbe047c92ee2cdffedb39f2a31 GitHub-Last-Rev: 64b6421503dfb9396e46f94f9805ff7f8bf2b31b GitHub-Pull-Request: golang/go#45839 Reviewed-on: https://go-review.googlesource.com/c/go/+/314969 Reviewed-by: Ian Lance Taylor <iant@golang.org> Reviewed-by: Rob Pike <r@golang.org>
2021-02-24bufio, bytes, strings: handle negative runes in WriteRuneDavid Benjamin
Updates #43254 Change-Id: I7d4bf3b99cc36ca2156af5bb01a1c595419d1d3c Reviewed-on: https://go-review.googlesource.com/c/go/+/280492 Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com> Reviewed-by: Rob Pike <r@golang.org> Trust: Emmanuel Odeke <emmanuel@orijtech.com> Run-TryBot: Emmanuel Odeke <emmanuel@orijtech.com> TryBot-Result: Go Bot <gobot@golang.org>
2020-11-28bufio: make string(int) conversion safersmasher164
Updates #42792. Change-Id: I7e53426c41e5609d9dadceb300f7983ba7ad6577 Reviewed-on: https://go-review.googlesource.com/c/go/+/273526 Run-TryBot: Akhil Indurti <aindurti@gmail.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> Reviewed-by: Robert Griesemer <gri@golang.org>
2020-10-20all: update references to symbols moved from io/ioutil to ioRuss Cox
The old ioutil references are still valid, but update our code to reflect best practices and get used to the new locations. Code compiled with the bootstrap toolchain (cmd/asm, cmd/dist, cmd/compile, debug/elf) must remain Go 1.4-compatible and is excluded. Also excluded vendored code. For #41190. Change-Id: I6d86f2bf7bc37a9d904b6cee3fe0c7af6d94d5b1 Reviewed-on: https://go-review.googlesource.com/c/go/+/263142 Trust: Russ Cox <rsc@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
2020-08-18all: fix spelling mistakeslihaowei
Change-Id: I7d512281d8442d306594b57b5deaecd132b5ea9e GitHub-Last-Rev: 251e1d6857516b21fd71f654133f81f23ffec654 GitHub-Pull-Request: golang/go#40793 Reviewed-on: https://go-review.googlesource.com/c/go/+/248441 Reviewed-by: Dave Cheney <dave@cheney.net>
2020-06-17bufio: test for exact error value in TestNegativeEOFReader and TestLargeReaderDmitri Shuralyov
CL 225357 added tests for Scanner not panicking on bad readers. CL 225557 created a named error value that is returned instead. CL 237739 documents that the bufio.ErrBadReadCount is returned when bufio.Scanner is used with an invalid io.Reader. This suggests we wouldn't want that behavior to be able to change without a test noticing it, so modify the tests to check for the exact error value instead of just any non-nil one. For #38053. Change-Id: I4b0b8eb6804ebfe2c768505ddb94f0b1017fcf8b Reviewed-on: https://go-review.googlesource.com/c/go/+/238217 Reviewed-by: Ian Lance Taylor <iant@golang.org>
2020-04-28bufio: optimize bufio.Reader.ReadString to avoid an allocation and copyAlex Gaynor
name old time/op new time/op delta ReaderReadString-4 226ns ±12% 161ns ±11% -28.76% (p=0.008 n=5+5) name old alloc/op new alloc/op delta ReaderReadString-4 288B ± 0% 144B ± 0% -50.00% (p=0.008 n=5+5) name old allocs/op new allocs/op delta ReaderReadString-4 2.00 ± 0% 1.00 ± 0% -50.00% (p=0.008 n=5+5) Change-Id: I77f330b8340c2bfbfff1f6f1000170b65953a200 GitHub-Last-Rev: 65d65302a7b80504b4d37b81a3843fe1439e638a GitHub-Pull-Request: golang/go#34706 Reviewed-on: https://go-review.googlesource.com/c/go/+/199257 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2020-03-25scan: for style, adjust code for bad scan read countsRob Pike
Make the code more consistent with the rest of the file. Should have caught this in review of CL 225357. Change-Id: I12824cb436539c31604684e043ebb7587cc92471 Reviewed-on: https://go-review.googlesource.com/c/go/+/225557 Reviewed-by: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org>
2020-03-25bufio: don't panic when Scanner sees an impossible Read countIan Lance Taylor
Fixes #38053 Change-Id: Ib0f9777f37eeaa07eb8ecb6df3e97e9d4b46dcd8 Reviewed-on: https://go-review.googlesource.com/c/go/+/225357 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Rob Pike <r@golang.org>
2020-02-26all: avoid string(i) where i has type intIan Lance Taylor
Instead use string(r) where r has type rune. This is in preparation for a vet warning for string(i). Updates #32479 Change-Id: Ic205269bba1bd41723950219ecfb67ce17a7aa79 Reviewed-on: https://go-review.googlesource.com/c/go/+/220844 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Akhil Indurti <aindurti@gmail.com> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: Toshihiro Shiino <shiino.toshihiro@gmail.com>
2019-10-31bufio: return the underlying error in ReadFrom if not nilCuong Manh Le
If a previous Write returned an error, any subsequent Write or ReadFrom must return that error before any operations. However, only Write behaved correctly and this change fixes that problem by making sure that ReadFrom firstly checks for the underlying error. Fixes #35194 Change-Id: I31356a9e8bd945bc0168b2e3be470f3ae69d4813 Reviewed-on: https://go-review.googlesource.com/c/go/+/204000 Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com> Reviewed-by: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-10-31bufio: save error from underlying ReadFromCuong Manh Le
Updates #35194 Change-Id: Ib854bc6250ddeb606d6ff6240179e23b98e4ac62 Reviewed-on: https://go-review.googlesource.com/c/go/+/203999 Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com> Reviewed-by: Ian Lance Taylor <iant@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-10-04bufio: simplify bufio.Reader.ReadBytes to avoid an extra loop over a sliceAlex Gaynor
Change-Id: Icb1c3eb30147180ba5949a25c65b48307b14c1ca GitHub-Last-Rev: 937ae8641321139b9165ce7d57abeac5a67dc24d GitHub-Pull-Request: golang/go#34704 Reviewed-on: https://go-review.googlesource.com/c/go/+/199157 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2019-06-25bufio: fix ExampleScanner_Bytes comment, add error checkIan Lance Taylor
Followup to CL 51412. Change-Id: Ic83c833e2c571cd7c8293d998ff745f181037a61 Reviewed-on: https://go-review.googlesource.com/c/go/+/183657 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Rob Pike <r@golang.org>
2019-06-21bufio: add example for Scanner.Bytesguitarbum722
Change-Id: I4a5c7573e13dd85531ee9f4dd2a0d1981bf8cdfa Reviewed-on: https://go-review.googlesource.com/c/go/+/51412 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2019-06-20bufio: Reader.Read may return io.EOF even when it has data bufferedDaniel Cormier
If reading 0 bytes, don't return the error from the underlying io.Reader if there is still data buffered. Fixes #32693 Change-Id: I12a97bd6003c638c15d41028942f27edf88340e2 Reviewed-on: https://go-review.googlesource.com/c/go/+/182997 Run-TryBot: Robert Griesemer <gri@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Robert Griesemer <gri@golang.org>
2019-05-23bufio: Fix typo in scan.go documentationMickey Reiss
Apologies for the the nitpicky PR. I believe there is a minor typo in the documentation of `MaxScanTokenSize`, which confused me for a moment when I went to search for the referenced method, `Scan.Buffer`. Thanks! Change-Id: I5d21e77276285206497fe75291001032c255cace GitHub-Last-Rev: 635e35c0191c11f2b6966b5e58cf91a1064099da GitHub-Pull-Request: golang/go#32193 Reviewed-on: https://go-review.googlesource.com/c/go/+/178637 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>