Skip to content

Commit 18ab7a0

Browse files
authored
autogenerated_exclude: increase scanner buffer (#955)
* autogenerated_exclude: increase scanner buffer Some lines can be very long, so increase scanner buffer to mitigate this. Fix #954
1 parent 4d165fc commit 18ab7a0

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

pkg/result/processors/autogenerated_exclude.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,15 @@ func getDoc(filePath string) (string, error) {
120120
defer file.Close()
121121

122122
scanner := bufio.NewScanner(file)
123+
124+
// Issue 954: Some lines can be very long, e.g. auto-generated
125+
// embedded resources. Reported on file of 86.2KB.
126+
const (
127+
maxSize = 512 * 1024 // 512KB should be enough
128+
initialSize = 4096 // same as startBufSize in bufio
129+
)
130+
scanner.Buffer(make([]byte, initialSize), maxSize)
131+
123132
var docLines []string
124133
for scanner.Scan() {
125134
line := strings.TrimSpace(scanner.Text())

0 commit comments

Comments
 (0)