Use larger buffer when ungron

This commit is contained in:
saka1 2018-08-25 03:06:26 +09:00
parent 404b80f960
commit a2fa995cab
4 changed files with 7 additions and 0 deletions

View file

@ -312,6 +312,9 @@ func ungron(r io.Reader, w io.Writer, opts int) (int, error) {
scanner := bufio.NewScanner(r)
var maker statementmaker
// Allow larger internal buffer of the scanner (min: 64KiB ~ max: 1MiB)
scanner.Buffer(make([]byte, 64*1024), 1024*1024)
if opts&optJSON > 0 {
maker = statementFromJSONSpec
} else {

View file

@ -137,6 +137,7 @@ func TestUngron(t *testing.T) {
{"testdata/three.gron", "testdata/three.json"},
{"testdata/grep-separators.gron", "testdata/grep-separators.json"},
{"testdata/github.gron", "testdata/github.json"},
{"testdata/large-line.gron", "testdata/large-line.json"},
}
for _, c := range cases {

2
testdata/large-line.gron vendored Normal file

File diff suppressed because one or more lines are too long

1
testdata/large-line.json vendored Normal file

File diff suppressed because one or more lines are too long