Skip to content

Commit

Permalink
Use larger buffer when ungron
Browse files Browse the repository at this point in the history
  • Loading branch information
saka1 committed Aug 24, 2018
1 parent 404b80f commit a2fa995
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 0 deletions.
3 changes: 3 additions & 0 deletions main.go
Expand Up @@ -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 {
Expand Down
1 change: 1 addition & 0 deletions main_test.go
Expand Up @@ -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 {
Expand Down
2 changes: 2 additions & 0 deletions testdata/large-line.gron

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions testdata/large-line.json

Large diffs are not rendered by default.

0 comments on commit a2fa995

Please sign in to comment.