Skip to content
This repository has been archived by the owner on Nov 9, 2022. It is now read-only.

Commit

Permalink
fix inital buffer size (r3labs#129)
Browse files Browse the repository at this point in the history
Correctly handle maxBufferSize for scanner buffer
  • Loading branch information
florianl authored Mar 8, 2022
1 parent c592a97 commit 9a15ccd
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion event.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ type EventStreamReader struct {
// NewEventStreamReader creates an instance of EventStreamReader.
func NewEventStreamReader(eventStream io.Reader, maxBufferSize int) *EventStreamReader {
scanner := bufio.NewScanner(eventStream)
scanner.Buffer(make([]byte, 4096), maxBufferSize)
initBufferSize := minPosInt(4096, maxBufferSize)
scanner.Buffer(make([]byte, initBufferSize), maxBufferSize)

split := func(data []byte, atEOF bool) (int, []byte, error) {
if atEOF && len(data) == 0 {
Expand Down

0 comments on commit 9a15ccd

Please sign in to comment.