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)
- The value is moved/copied into a
json_element rvalue instance
- That
json_element is then moved into pair instance
- 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.
Currently implicit inserts in
json_arrayandjson_objectwrap the inserted type, whetherjson_element,dynamic_stringor some primitive type in anotherjson_elementasFirstly, this is redundant when inserting
json_elementbut I also suspect that, for other types, this introduces one unnecessary move/copy operation, that is, (assumingval_tis not `json_element)json_elementrvalue instancejson_elementis then moved intopairinstancejson_elementis moved into the containerIf 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 arraypush_back,push_front,insertetc.