Skip to content

Commit 739c75e

Browse files
committed
Fix missing move and bare new in pytree from_str_internal
Just a couple minor fixes. Differential Revision: [D65576543](https://our.internmc.facebook.com/intern/diff/D65576543/) [ghstack-poisoned]
1 parent c5f21bc commit 739c75e

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

extension/pytree/pytree.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,8 @@ struct ContainerHandle {
138138

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

141+
/*implicit*/ ContainerHandle(std::unique_ptr<container_type> c) : handle(std::move(c)) {}
142+
141143
void set_leaf(leaf_type* leaf) {
142144
pytree_assert(handle->kind == Kind::Leaf);
143145
handle->leaf = leaf;
@@ -485,10 +487,10 @@ TreeSpec<Aux> from_str_internal(
485487
read_idx++;
486488
auto layout = read_node_layout(spec, read_idx);
487489
const auto size = layout.size();
488-
auto c = new TreeSpecContainer<Aux>(kind, size);
490+
auto c = std::make_unique<TreeSpecContainer<Aux>>(kind, size);
489491

490492
if (Kind::Custom == kind) {
491-
c->custom_type = custom_type;
493+
c->custom_type = std::move(custom_type);
492494
}
493495

494496
size_t child_idx = 0;
@@ -515,7 +517,7 @@ TreeSpec<Aux> from_str_internal(
515517
read_idx++;
516518
auto layout = read_node_layout(spec, read_idx);
517519
const auto size = layout.size();
518-
auto c = new TreeSpecContainer<Aux>(Kind::Dict, size);
520+
auto c = std::make_unique<TreeSpecContainer<Aux>>(Kind::Dict, size);
519521

520522
size_t child_idx = 0;
521523
size_t leaves_offset = 0;

0 commit comments

Comments
 (0)