mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
bytes: hoist error creation out of function
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 <mpvl@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Russ Cox <rsc@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
This commit is contained in:
parent
c55eeeb718
commit
ef954a03eb
1 changed files with 3 additions and 1 deletions
|
|
@ -385,13 +385,15 @@ func (b *Buffer) UnreadRune() error {
|
|||
return nil
|
||||
}
|
||||
|
||||
var errUnreadByte = errors.New("bytes.Buffer: UnreadByte: previous operation was not a successful read")
|
||||
|
||||
// UnreadByte unreads the last byte returned by the most recent successful
|
||||
// read operation that read at least one byte. If a write has happened since
|
||||
// the last read, if the last read returned an error, or if the read read zero
|
||||
// bytes, UnreadByte returns an error.
|
||||
func (b *Buffer) UnreadByte() error {
|
||||
if b.lastRead == opInvalid {
|
||||
return errors.New("bytes.Buffer: UnreadByte: previous operation was not a successful read")
|
||||
return errUnreadByte
|
||||
}
|
||||
b.lastRead = opInvalid
|
||||
if b.off > 0 {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue