Skip to content

Efficiency of implicit inserts #14

@Mogball

Description

@Mogball

Currently implicit inserts in json_array and json_object wrap the inserted type, whether json_element, dynamic_string or some primitive type in another json_element as

insert(json_element(forward<val_t>(val)));

Firstly, this is redundant when inserting json_element but I also suspect that, for other types, this introduces one unnecessary move/copy operation, that is, (assuming val_t is not `json_element)

  1. The value is moved/copied into a json_element rvalue instance
  2. That json_element is then moved into pair instance
  3. Upon insertion, the said json_element is moved into the container

If we could open up the container machinery we could cut out the middle step and move/copy the value directly into the container.

This applies for object insert, insert_or_assign, and array push_back, push_front, insert etc.

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