CocosNode.remove() performances

22 views
Skip to first unread message

Nitneroc

unread,
Aug 25, 2012, 9:35:27 AM8/25/12
to cocos-...@googlegroups.com
I guess my use-case is very specific, but the performances of CocosNode._remove() are really important to me.
Once again, this is very specific, but in one of my batches, there is no z-ordering of the ~10k sprites (they all are at z=0), so I changed the _remove() function to this one :

def _remove( self, child ):
        self.children.remove((0,child))
        if self.is_running:
            child.on_exit()

It seems that execution time went from 12.56ms to 0.75ms.

I was wondering if it could be interesting to store somewhere (read-only) in CocosNode the z-order they were added with, and use it in _remove().
I'm probably the only one interested in removing many Nodes at high speed, though :D

Nitneroc

unread,
Aug 25, 2012, 10:27:29 AM8/25/12
to cocos-...@googlegroups.com
I just realized, this would mean 8 bytes more per node, and i'm talking about 10,000 of them... That's probably a bad idea !
Reply all
Reply to author
Forward
0 new messages