Prevent infinite looping in GetString on certain malformed strings #167
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description: This PR is to address the open issue: #164
Benchmark before change:
goos: darwin
goarch: amd64
pkg: github.com/buger/jsonparser/benchmark
BenchmarkJsonParserLarge-8 200000 49082 ns/op 0 B/op 0 allocs/op
BenchmarkJsonParserMedium-8 1000000 7254 ns/op 0 B/op 0 allocs/op
BenchmarkJsonParserDeleteMedium-8 1000000 7638 ns/op 0 B/op 0 allocs/op
BenchmarkJsonParserEachKeyManualMedium-8 1000000 5123 ns/op 112 B/op 2 allocs/op
BenchmarkJsonParserEachKeyStructMedium-8 1000000 5726 ns/op 544 B/op 12 allocs/op
BenchmarkJsonParserObjectEachStructMedium-8 1000000 7774 ns/op 496 B/op 11 allocs/op
BenchmarkJsonParserSmall-8 10000000 766 ns/op 0 B/op 0 allocs/op
BenchmarkJsonParserEachKeyManualSmall-8 10000000 616 ns/op 80 B/op 2 allocs/op
BenchmarkJsonParserEachKeyStructSmall-8 10000000 1192 ns/op 192 B/op 8 allocs/op
BenchmarkJsonParserObjectEachStructSmall-8 10000000 784 ns/op 176 B/op 7 allocs/op
BenchmarkJsonParserSetSmall-8 10000000 1105 ns/op 768 B/op 4 allocs/op
BenchmarkJsonParserDelSmall-8 5000000 1388 ns/op 0 B/op 0 allocs/op
PASS
ok github.com/buger/jsonparser/benchmark 101.571s
Benchmark after change:
goos: darwin
goarch: amd64
pkg: github.com/buger/jsonparser/benchmark
BenchmarkJsonParserLarge-8 200000 47197 ns/op 0 B/op 0 allocs/op
BenchmarkJsonParserMedium-8 1000000 7353 ns/op 0 B/op 0 allocs/op
BenchmarkJsonParserDeleteMedium-8 1000000 7470 ns/op 0 B/op 0 allocs/op
BenchmarkJsonParserEachKeyManualMedium-8 1000000 5169 ns/op 112 B/op 2 allocs/op
BenchmarkJsonParserEachKeyStructMedium-8 1000000 5568 ns/op 544 B/op 12 allocs/op
BenchmarkJsonParserObjectEachStructMedium-8 1000000 7740 ns/op 496 B/op 11 allocs/op
BenchmarkJsonParserSmall-8 10000000 750 ns/op 0 B/op 0 allocs/op
BenchmarkJsonParserEachKeyManualSmall-8 20000000 621 ns/op 80 B/op 2 allocs/op
BenchmarkJsonParserEachKeyStructSmall-8 10000000 835 ns/op 192 B/op 8 allocs/op
BenchmarkJsonParserObjectEachStructSmall-8 10000000 721 ns/op 176 B/op 7 allocs/op
BenchmarkJsonParserSetSmall-8 10000000 1100 ns/op 768 B/op 4 allocs/op
BenchmarkJsonParserDelSmall-8 5000000 1565 ns/op 0 B/op 0 allocs/op
PASS
ok github.com/buger/jsonparser/benchmark 104.016s
For running benchmarks use: