GUDHI/gudhi-devel

Use the new Simplex_tree.clear function

mglisse opened this issue · 2 comments

# Delete pointer, just in case, as deserialization requires an empty SimplexTree
cdef Simplex_tree_python_interface* ptr = self.get_ptr()
del ptr
self.thisptr = <intptr_t>(new Simplex_tree_python_interface())

Would using ptr->clear() work, now that we have that function? It isn't 100% equivalent, and the vector of vertices keeps its capacity, but I don't think we care about the difference.
I didn't check if there are other places where we delete&recreate a Simplex_tree to clear it.

After verifying, it seems interesting to use clear method in collapse_edges SimplexTree method. I will propose another PR

I do not see any other places where we delete and recreate a Simplex tree to clear it.
I close it, but do not hesitate to open a new issue if any other places are found.