Skip to content

Commit

Permalink
fix: Changed per feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
stuartcarnie committed Sep 29, 2020
1 parent f4f1fa1 commit b3b8f9e
Showing 1 changed file with 1 addition and 10 deletions.
11 changes: 1 addition & 10 deletions write/batcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,6 @@ func (b *Batcher) Write(ctx context.Context, org, bucket platform.ID, r io.Reade
return nil
}

func min(a, b int) int {
if a < b {
return a
}
return b
}

// read will close the line channel when there is no more data, or an error occurs.
// it is possible for an io.Reader to block forever; Write's context can be
// used to cancel, but, it's possible there will be dangling read go routines.
Expand All @@ -85,9 +78,7 @@ func (b *Batcher) read(ctx context.Context, r io.Reader, lines chan<- []byte, er
if b.MaxLineLength > 0 {
maxLineLength = b.MaxLineLength
}

// limit the initial size of the buffer to a maximum of bufio.MaxScanTokenSize bytes
scanner.Buffer(make([]byte, min(bufio.MaxScanTokenSize, maxLineLength)), maxLineLength)
scanner.Buffer(nil, maxLineLength)

for scanner.Scan() {
// exit early if the context is done
Expand Down

0 comments on commit b3b8f9e

Please sign in to comment.