Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions extension/pytree/pytree.h
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,9 @@ struct ContainerHandle {

/*implicit*/ ContainerHandle(container_type* c) : handle(c) {}

/*implicit*/ ContainerHandle(std::unique_ptr<container_type> c)
: handle(std::move(c)) {}

void set_leaf(leaf_type* leaf) {
pytree_assert(handle->kind == Kind::Leaf);
handle->leaf = leaf;
Expand Down Expand Up @@ -486,10 +489,10 @@ TreeSpec<Aux> from_str_internal(
read_idx++;
auto layout = read_node_layout(spec, read_idx);
const auto size = layout.size();
auto c = new TreeSpecContainer<Aux>(kind, size);
auto c = std::make_unique<TreeSpecContainer<Aux>>(kind, size);

if (Kind::Custom == kind) {
c->custom_type = custom_type;
c->custom_type = std::move(custom_type);
}

size_t child_idx = 0;
Expand All @@ -509,14 +512,14 @@ TreeSpec<Aux> from_str_internal(
read_idx++;
}
c->leaves_num = leaves_offset;
return c;
return TreeSpec<Aux>(std::move(c));
}

case Config::kDict: {
read_idx++;
auto layout = read_node_layout(spec, read_idx);
const auto size = layout.size();
auto c = new TreeSpecContainer<Aux>(Kind::Dict, size);
auto c = std::make_unique<TreeSpecContainer<Aux>>(Kind::Dict, size);

size_t child_idx = 0;
size_t leaves_offset = 0;
Expand Down Expand Up @@ -549,7 +552,7 @@ TreeSpec<Aux> from_str_internal(
read_idx++;
}
c->leaves_num = leaves_offset;
return c;
return TreeSpec<Aux>(std::move(c));
}

case Config::kLeaf:
Expand Down
Loading