Skip to content

Conversation

@geraldcombs
Copy link

This change adds the ability to fetch value offsets and lengths.

I needed to fetch value offsets and lengths in some code that was uses fastjson, so I rewrote the parser to operate only on the original string supplied in Parse, and to store the data offset and length of each along with its other attributes.

The best of 3 runs of go test -bench . on my machine shows a ~ 1.7% slowdown, which is fine for my use case:

valyala/fastjson@v1.6.4: 146.663s
geraldcombs/fastjson@value-offsets: 149.130s

I don't claim to be a Go expert, so it wouldn't surprise me if there was room for optimization.

Instead of using substrings as we scan through our data, use the
original string and an offset. This lets us track and store the start
offset and length of each value.
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.

1 participant