mirror of
https://github.com/golang/go
synced 2024-11-18 08:04:40 -07:00
bufio: use max/min func
Change-Id: I52875f8dd4bbdc9296ba8e4f801356047ee14e62
GitHub-Last-Rev: dfb2a343e6
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>
This commit is contained in:
parent
a1eb658d18
commit
774d001d17
@ -50,11 +50,8 @@ func NewReaderSize(rd io.Reader, size int) *Reader {
|
||||
if ok && len(b.buf) >= size {
|
||||
return b
|
||||
}
|
||||
if size < minReadBufferSize {
|
||||
size = minReadBufferSize
|
||||
}
|
||||
r := new(Reader)
|
||||
r.reset(make([]byte, size), rd)
|
||||
r.reset(make([]byte, max(size, minReadBufferSize)), rd)
|
||||
return r
|
||||
}
|
||||
|
||||
|
@ -198,9 +198,7 @@ func (s *Scanner) Scan() bool {
|
||||
if newSize == 0 {
|
||||
newSize = startBufSize
|
||||
}
|
||||
if newSize > s.maxTokenSize {
|
||||
newSize = s.maxTokenSize
|
||||
}
|
||||
newSize = min(newSize, s.maxTokenSize)
|
||||
newBuf := make([]byte, newSize)
|
||||
copy(newBuf, s.buf[s.start:s.end])
|
||||
s.buf = newBuf
|
||||
|
Loading…
Reference in New Issue
Block a user