YaRiabtsev / json-eval

A C++ console application that allows evaluating expressions on a JSON file.
https://yariabtsev.github.io/json-eval/
MIT License
1 stars 0 forks source link

avoid unnecessary touching #5

Open YaRiabtsev opened 3 weeks ago

YaRiabtsev commented 3 weeks ago

void touch() duplicates the logic of void set_root(const std::shared_ptr<json>& item) and void set_parent(const std::shared_ptr<json>& local): for non-dynamic jsons it makes no sense to call touch() and traverse the whole object, so it is worth considering combining set_parent and set_root, getting rid of touch. When traversing it is enough to look at json_reference and if head is_local - use set_parent logic, otherwise - set_root. Additionally: add bool is_local() as a method for json_reference.