-
Notifications
You must be signed in to change notification settings - Fork 434
internalGet: truncate capacity on return value #199
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Follow-up: It was pointed out to me that the write side is probably fine to use the extra capacity, in which case, the |
FYI we ended up going with: Line 916 in f7e751e
return value[:len(value):len(value)], dataType, offset, endOffset, nil |
Awesome! Thanks! I prefer to restrict the capacity of the slice returned by the |
Sweet! |
I'm gonna go ahead and close this so it drops out of my list of things |
Using
ArrayEach
in concert withSet
leads to some weird behavior. Specifically thatArrayEach
provides slices over the original json object, such that the capacity of the slice isjsonEnd-(startOffsetOfSlice)
. This interacts poorly withSet
when a particular key does not exist in the object being mutated. Given this testcase, you can see the output shows the second JSON object becoming malformed upon setting a non-existent key in the first object.The suggested fix is to change this line:
jsonparser/parser.go
Line 794 in f7e751e
to
which truncates the capacity causing
append
to allocate a new slice. Alternatively, the pattern in thepath currently exists
flow can be used, this just happened to be a nifty one-linerThe text was updated successfully, but these errors were encountered: