Skip to content

Arrayeach early termination#134

Open
xphil wants to merge 2 commits intobuger:masterfrom
xphil:arrayeach-early-termination
Open

Arrayeach early termination#134
xphil wants to merge 2 commits intobuger:masterfrom
xphil:arrayeach-early-termination

Conversation

@xphil
Copy link

@xphil xphil commented Apr 16, 2018

Description: What this PR does
Added ability to terminate ArrayEach() from within its callback, by setting error to some value.
Previous implementation didn't make much sense, since error was always nil.

Benchmark before change:
Benchmark is currently broken, but this fix should not change benchmark times in any way. Might fix benchmark later.

Benchmark after change:

For running benchmarks use:

go test -test.benchmem -bench JsonParser ./benchmark/ -benchtime 5s -v
# OR
make bench (runs inside docker)

xphil added 2 commits April 16, 2018 03:45
Added ability to terminate ArrayEach() from within its callback, by setting
error to some value.
Previous implementation didn't make much sense, since error was always nil.
@jlhawn
Copy link

jlhawn commented Nov 13, 2018

@xphil I just noticed this PR, after I opened #156

What do you think of that patch? It's a similar goal as this one except it has the callback return an error. I also fixed the benchmarks to get them to run again.

securityguy added a commit to securityguy/jsonparser that referenced this pull request Mar 18, 2026
…nhancements

Module renamed from github.com/buger/jsonparser to github.com/securityguy/jsonparser.

Security fixes:
- Fix GO-2026-4514: Delete() panics on malformed JSON (negative slice index DoS)
- Update Dockerfile base image from golang:1.6 to golang:1.21

Bug fixes:
- Fix EachKey failing to extract values from arrays of strings (PR buger#180)
- Remove duplicate import in parser_test.go (PR buger#263)

New APIs (all additive):
- ArrayEach callback now accepts *error for early termination; DoneError sentinel added (PR buger#134)
- DeleteOnOrig: in-place deletion variant with no allocation (PR buger#256)
- ArrayIterator: lazy closure-based array iteration (PR buger#254)
- GetRaw, EachRawKey: raw JSON byte extraction without type parsing (PR buger#250)

Other:
- go.mod bumped to go 1.18
- benchmark/go.mod updated with replace directive pointing to local module
- CLAUDE.md added for Claude Code guidance

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants