modernize: Use min built-in

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
This commit is contained in:
Paweł Gronowski
2025-12-15 18:25:30 +01:00
parent 39c19d9161
commit e548a31d28
11 changed files with 13 additions and 52 deletions

View File

@@ -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

View File

@@ -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 {