Nelarius / imnodes

A small, dependency-free node editor for dear imgui
MIT License
2.01k stars 244 forks source link

Object pool cleanup #81

Open Nelarius opened 3 years ago

Nelarius commented 3 years ago

Primary concerns

Iterating over all nodes, both used and unused, seems to cause continuous issues due to the complicated logic in the object pool and free list usage: https://github.com/Nelarius/imnodes/issues/71, https://github.com/Nelarius/imnodes/issues/59, https://github.com/Nelarius/imnodes/issues/58

We should only iterate over the nodes which have actually been submitted this frame. We already maintain the list of submitted node indices, so it could be used for this purpose as well.

Once this is done, this commit can be reverted: https://github.com/Nelarius/imnodes/commit/f1bda7257d3eb0bb1942e465c4174211ae577f29.

Secondary concerns

  1. ObjectPool::free_list is updated every frame. It should be enough to add the free slot once to the list and retain it.
  2. ObjectPool::in_use is not needed, if we can compare the submission indices of this frame and the previous frame.