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
This commit is contained in:
Aleksandr Razumov 2020-02-03 20:42:30 +03:00 committed by GitHub
parent 4d165fc2dd
commit 18ab7a0005
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -120,6 +120,15 @@ func getDoc(filePath string) (string, error) {
defer file.Close()
scanner := bufio.NewScanner(file)
// Issue 954: Some lines can be very long, e.g. auto-generated
// embedded resources. Reported on file of 86.2KB.
const (
maxSize = 512 * 1024 // 512KB should be enough
initialSize = 4096 // same as startBufSize in bufio
)
scanner.Buffer(make([]byte, initialSize), maxSize)
var docLines []string
for scanner.Scan() {
line := strings.TrimSpace(scanner.Text())