Monday, August 16, 2010

Containers, rewritten

There have been a number of things, recently, that have come up during v2.0 development that could negatively affect performance in the future.  Additionally, these issues had started to manifest themselves in Chrome and Firefox 4.0.  So, to try and fix the main issue I rewrote the Container class to be a linked list, rather than a simple array.  It may seem counterproductive to change from the native Array object, especially since it has all those fantastic methods for filtering and such, but overall I've seen a slight improvement in performance.  It isn't huge, but it's there...

Doing so also allowed me to update the Iterator class so that it would not be negatively affected by changing the backing container.  As such, the iterators can be safely used without needing to worry about whether an object in the container has been destroyed.  This is due to the fact that iterators will intuitively detect which objects are included in the iteration and skip over those that should be excluded.

Unfortunately, as with any change to a core class such as Container has its drawbacks.  One such issue is that when a container is destroyed, it no longer destroys the objects it contains.  This isn't a big issue, as you can still call the cleanUp() method of Container.  But it will be a sticking point for some who've already started using The Render Engine for their game development and choose to work from the SVN trunk.

No comments:

Post a Comment