Skip to content
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

Resusing json_tokener object #284

Closed
usergoodvery opened this issue Nov 6, 2016 · 3 comments
Closed

Resusing json_tokener object #284

usergoodvery opened this issue Nov 6, 2016 · 3 comments

Comments

@usergoodvery
Copy link

Hi,
Is it it save to reuse json_tokener object across (non-concurrent, but successive) to json_tokener_parse_ex() or one must issue json_tokener_free() between each call to json_tokener_parse_ex()?

regards

@hawicz
Copy link
Member

hawicz commented Nov 7, 2016

I you call json_tokener_reset() you can re-use the same json_tokener object. That'll save you about 4 calls to free() over called json_tokener_free().

@hawicz hawicz closed this as completed Nov 7, 2016
@usergoodvery
Copy link
Author

That's great... is there an equivalent of that for json_object to avoid calling put/new

@hawicz
Copy link
Member

hawicz commented Nov 7, 2016

No, and it doesn't make sense to have one for most object types since you can't change them. For a json_type_object or json_type_array you can just remove all of its elements and remove it from its containing object (if any) to do roughly the equivalent of "reset". However, if your goal is performance I suspect you'll find this to be of limited impact, especially for object trees of any size, and you efforts are probably best spent elsewhere.

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

No branches or pull requests

2 participants