aboutsummaryrefslogtreecommitdiff
path: root/src/bufio
AgeCommit message (Collapse)Author
2024-01-25bufio: realign struct Scannerbench-beforeShulhan
This reduce the Scanner allocation size from 112 to 72 bytes.
2024-01-25bufio: realign struct ReaderShulhan
This reduce the Reader allocation size from 72 to 40 bytes and Writer allocation size from 64 to 40 bytes.
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>
2019-03-02bufio: fix emptyFinalToken example to handle multiple ReadsAgniva De Sarker
Fixes #25909 Change-Id: I9a53a1a06aab5d1877a8e9b1b8b782d77d6027a8 Reviewed-on: https://go-review.googlesource.com/c/157758 Reviewed-by: Bryan C. Mills <bcmills@google.com> Run-TryBot: Bryan C. Mills <bcmills@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-01-08bufio: document relationship between UnreadByte/UnreadRune and PeekBrad Fitzpatrick
Fixes #29387 Change-Id: I2d9981f63ac16630ed39d6da6692c81396f4e9ea Reviewed-on: https://go-review.googlesource.com/c/155930 Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-11-13bufio: make Reader.Peek invalidate UnreadsMartin Garton
Since Reader.Peek potentially reads from the underlying io.Reader, discarding previous buffers, UnreadRune and UnreadByte cannot necessarily work. Change Peek to invalidate the unread buffers in all cases (as allowed according to the documentation) and thus prevent hiding bugs in the caller. (This change was previoiusly merged and then reverted due concern about being too close to a release) Fixes #18556 Change-Id: I9027d75aa834d4b27703f37711ba25de04d89f3c GitHub-Last-Rev: 917ef1e51131d734f92efc946a0ab5ca4ff69be6 GitHub-Pull-Request: golang/go#28768 Reviewed-on: https://go-review.googlesource.com/c/149297 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-11-13bufio: put notes about len(p) togetherRuss Cox
CL 145577 added the part about io.ReadFull to read len(p) but it should be next to the existing sentence about not reading len(p) bytes. Change-Id: Idfa037c59a3085d44d5da6129188473db0e96d23 Reviewed-on: https://go-review.googlesource.com/c/148903 Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: Alan Donovan <adonovan@google.com>
2018-11-09bufio: fix indexes in TestWriterRyan Dahl
Change-Id: I393c53d6f7b526d156226502544725a4cb9fb118 GitHub-Last-Rev: 5d53406c70ebbbbedd7650b9f43c873ead63c184 GitHub-Pull-Request: golang/go#28693 Reviewed-on: https://go-review.googlesource.com/c/148818 Run-TryBot: Ian Lance Taylor <iant@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-10-30bufio: suggest io.ReadFull at (*Reader).ReadAlan Donovan
Many times when using bufio.Reader I imagine, incorrectly, that it implements the retry loop itself, being a high-level buffered wrapper around, say, a file descriptor prone to short reads. This comment would have saved me much time. Change-Id: I34c790e0d7c1515430a76d02ce4739b586a36ba7 Reviewed-on: https://go-review.googlesource.com/c/145577 Reviewed-by: Ian Lance Taylor <iant@golang.org> Reviewed-by: Rob Pike <r@golang.org>
2018-08-22bufio: avoid rescanning buffer multiple times in ReadSliceandrius4669
When existing data in buffer does not have delimiter, and new data is added with b.fill(), continue search from previous point instead of starting from beginning. Change-Id: Id78332afe2b0281b4a3c86bd1ffe9449cfea7848 GitHub-Last-Rev: 08e7d2f50151a00b22800e3f7020d0de8dee7dcf GitHub-Pull-Request: golang/go#25441 Reviewed-on: https://go-review.googlesource.com/113535 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-08-20bufio: make Reader naming consistentnogoegst
All the readers are denoted as `b` while for `Reader.Size()` it is `r`. Change-Id: Ib6f97306c11b3abb2ff30edbc9f9362cad36d080 GitHub-Last-Rev: 992f88b374b5a309303b7fa1622ee629d0fb741b GitHub-Pull-Request: golang/go#26205 Reviewed-on: https://go-review.googlesource.com/122156 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-06-13bufio: clarify SplitFunc docs for nil tokenIan Lance Taylor
Fixes #25472 Change-Id: Idb72ed06a3dc43c49ab984a80f8885352b036465 Reviewed-on: https://go-review.googlesource.com/118695 Reviewed-by: Rob Pike <r@golang.org>
2018-03-28bufio: document ReadFrom/WriteTo calls to underlying methodsIan Lance Taylor
In general use of these magic methods must be documented so that users understand what will happen. Fixes #23289 Change-Id: Ic46915eee1d3b7e57d8d1886834ddfb2e8e66e62 Reviewed-on: https://go-review.googlesource.com/103238 Reviewed-by: Rob Pike <r@golang.org>