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

Create an iterator for Jsmn::Object arrays #15

Closed
ZmnSCPxj opened this issue Nov 5, 2020 · 1 comment
Closed

Create an iterator for Jsmn::Object arrays #15

ZmnSCPxj opened this issue Nov 5, 2020 · 1 comment

Comments

@ZmnSCPxj
Copy link
Owner

ZmnSCPxj commented Nov 5, 2020

Currently, we iterate over JSON arrays by using a standard for-i-from-0-to-length loop. Then we index the JSON array by [i] syntax. Unfortunately, due to how JSMN structures are, the [i] lookup is O(n), so iteration is O(n^2).

We can instead use an iterator, which only requires a operator++ operation, which can be O(1) with the JSMN structures. This probably requires that array Jsmn::Object wrappers cache their end iterator.

@ZmnSCPxj
Copy link
Owner Author

Fixed. An iterator is now available, which should lead to faster processing of JSON results. Not all possible use-cases have been changed to use iterators, but the heavy hogs (mostly channel finders) have been updated appropriately.

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

1 participant