-
Notifications
You must be signed in to change notification settings - Fork 985
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
Reverting iter to previous position #1952
Comments
With all issues having to do with performance, we really want to have measurements (benchmarks). This being said, what you describe is not too difficult to implement but we really would like to have to benchmarks supporting our beliefs especially if we make the API more complex. |
Pull request invited. |
It's been a minute, but I think it does actually return to the existing field position. To find out whether the field exists, it has to cycle through all the fields, including the initial ones. |
@jkeiser The The default (operator[]) is It is a matter of semantics at this point because the current behaviour is that `find_field("x")...find_field("y")...find_field("z")..." only succeeds if you have the fields x, y, and z in sequence. If the field y is missing, then you have to reset the object. You don't have to do that with the default ( (I think all of that was written and designed by @jkeiser, to be clear.) |
The only missing find method is to find until end, and if not found, keeps previous position. It would be faster than find_field_unordered for ordered optional field. |
One good method that would solve that specific problem would be something like find_one_of("optional1", "optional2", "next_required_field") and have it return not only the value but tell you which one it found. That way you don't skip all the way to the end for an optional field in the first place. |
There would be lots of ways for different use case, but users are limited to existing methods, as there is no way to save/restore iterator position. |
In the case of using a one-pass version of the parser (using "find_fileld"), if the field is not found, then the object has to be reset, which is logical, but not for the case when we expect that there may not be a value with the passed keys. This results in performance degradation as we reprocess the keys. This can be avoided by adding the ability to remember the position of the iterator.
Make something like this
The text was updated successfully, but these errors were encountered: