Skip to content

Add a new function DeleteOnOrig - #256

Closed
crowfrog wants to merge 2 commits into
buger:masterfrom
crowfrog:master
Closed

Add a new function DeleteOnOrig#256
crowfrog wants to merge 2 commits into
buger:masterfrom
crowfrog:master

Conversation

@crowfrog

@crowfrog crowfrog commented Oct 8, 2022

Copy link
Copy Markdown

Description: add a new function DeleteOnOrig which can do delete operation on original slice. It will really help improve performance by reducing one memory alloc/dealloc and one whole copy per one call.

Benchmark before change:

Benchmark after change:

These is no benchmark case because no new code introduced almost.

@crowfrog

crowfrog commented Oct 9, 2022

Copy link
Copy Markdown
Author

@buger @daboyuka @AllenX2018

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>
@buger

buger commented Jul 28, 2026

Copy link
Copy Markdown
Owner

Closing — this PR's DeleteOnOrig deletes in-place on the caller's input buffer, which directly contradicts the no_input_mutation obligation added in v1.3.1. v1.3.1 specifically FIXED the bug where Set/Delete corrupted the caller's input via shared backing-array capacity (issues #209, #141). Reintroducing in-place mutation would regress that fix and violate the formal proof contract (SYS-REQ-009/010 now carry the no_input_mutation obligation). For detecting whether Delete found the key, use DeleteFound (v1.4.0) which returns ([]byte, bool) without mutating the input.

@buger buger closed this Jul 28, 2026
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