optimize move constructor

This commit is contained in:
MihailRis
2024-09-17 01:17:27 +03:00
parent 27c8307562
commit a886404940
2 changed files with 44 additions and 34 deletions
+10 -4
View File
@@ -52,9 +52,9 @@ namespace dv {
throw std::runtime_error("value is not a list");
}
value& value::add(value v) {
void value::add(value v) {
if (type == value_type::list) {
return val.list->add(std::move(v));
return val.list->push(std::move(v));
}
throw std::runtime_error("value is not a list");
}
@@ -72,11 +72,17 @@ namespace dv {
}
value& value::object() {
return add(dv::object());
if (type == value_type::list) {
return val.list->add(std::make_shared<objects::Object>());
}
throw std::runtime_error("value is not a list");
}
value& value::list() {
return add(dv::list());
if (type == value_type::list) {
return val.list->add(std::make_shared<objects::List>());
}
throw std::runtime_error("value is not a list");
}
list_t::iterator value::begin() {