Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
lib: Avoid O(N^2) behavior on cleanup
This library was written in a very general way with an API `lcfs_node_remove_child` that required removing an arbitrary member of the children array. I found a bug in that code previously in that it should have been using `memmove`, not `memcpy`. However, I think there's no need for us to support arbitrary tree computations. Today at process exit we walk over the in-memory filesystem and we end up with an O(N^2) behavior because we keep removing the first child. Instead, because we *only* need to care about removing all children at once, just iterate over them and then free them as we go. Note: I only noticed this code because of the `memmove` fix, not because I saw some performance problem in practice. It turns out computers are fast... Signed-off-by: Colin Walters <walters@verbum.org>
- Loading branch information