mirror of
https://github.com/moby/moby.git
synced 2026-01-11 18:51:37 +00:00
modernize: Use min built-in
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
This commit is contained in:
@@ -103,10 +103,7 @@ func NewTailReaderWithDelimiter(ctx context.Context, r SizeReaderAt, reqLines in
|
||||
|
||||
func newScanner(r SizeReaderAt, delim []byte) *scanner {
|
||||
size := r.Size()
|
||||
readSize := blockSize
|
||||
if readSize > int(size) {
|
||||
readSize = int(size)
|
||||
}
|
||||
readSize := min(blockSize, int(size))
|
||||
// silly case...
|
||||
if len(delim) >= readSize/2 {
|
||||
readSize = len(delim)*2 + 2
|
||||
@@ -178,10 +175,7 @@ func (s *scanner) Scan(ctx context.Context) bool {
|
||||
|
||||
idx := s.idx - len(s.delim)
|
||||
if idx < 0 {
|
||||
readSize := int(s.pos)
|
||||
if readSize > len(s.buf) {
|
||||
readSize = len(s.buf)
|
||||
}
|
||||
readSize := min(int(s.pos), len(s.buf))
|
||||
|
||||
if readSize < len(s.delim) {
|
||||
return false
|
||||
|
||||
@@ -210,10 +210,7 @@ func TestNewTailReader(t *testing.T) {
|
||||
test := test
|
||||
t.Parallel()
|
||||
|
||||
maxLen := len(test.data)
|
||||
if maxLen > 10 {
|
||||
maxLen = 10
|
||||
}
|
||||
maxLen := min(len(test.data), 10)
|
||||
|
||||
s := strings.Join(test.data, string(delim))
|
||||
if len(test.data) > 0 {
|
||||
|
||||
Reference in New Issue
Block a user