Skip to content

Reverting iter to previous position #1952

@avekarpov

Description

@avekarpov

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.

Result result;

auto error = object.find_field(key).get(result);

switch (error) {
    case simdjson::error_code::SUCCESS:
        break;

    case simdjson::error_code::NO_SUCH_FIELD:
        object.reset();
        break;

    default:
        ...
}

Make something like this

auto position = object.get_current_position();

Result result;

auto error = object.find_field(key).get(result);

switch (error) {
    case simdjson::error_code::SUCCESS:
        break;

    case simdjson::error_code::NO_SUCH_FIELD:
        object.revert_position(position);
        break;

    default:
        ...
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions