Skip to content

Commit 492dc1f

Browse files
schreier-sims: avoid allocating on stack in copy and __copy__
1 parent 13a95b8 commit 492dc1f

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

src/schreier-sims.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,14 @@ the list *gens*.
7878
for this class, or the number of generators exceeds the maximum capacity.
7979
)pbdoc");
8080

81-
thing.def("__copy__",
82-
[](SchreierSims_ const& self) { return SchreierSims_(self); });
81+
thing.def("__copy__", [](SchreierSims_ const& self) {
82+
return std::make_unique<SchreierSims_>(self);
83+
});
8384
thing.def(
8485
"copy",
85-
[](SchreierSims_ const& self) { return SchreierSims_(self); },
86+
[](SchreierSims_ const& self) {
87+
return std::make_unique<SchreierSims_>(self);
88+
},
8689
R"pbdoc(
8790
:sig=(self: SchreierSims) -> SchreierSims:
8891

0 commit comments

Comments
 (0)