ok, but between a ccArray and a CCArray?
CCArray: Performance and usability
(43 posts) (14 voices)-
Posted 1 year ago #
-
Posted 1 year ago #
-
I like this macro and started using it pretty much. Though I have one question...
What you think about making CCARRAY_FOREACH iterating backwards? That way we can easily remove objects from array during iteration instead of making temporary mutable arrays or similar workarounds.
Thanks
Posted 1 year ago # -
@crmagicxxx: I think that it's possible to remove objects while iterating from a
CCArray, or at least from the innerccCArray.
Also, I wouldn't modify the iteration direction since it might cause some bugs.regarding CCArray, this bug #901 is the one that is blocking v0.99.4-rc3 (last rc).
But I can't fix it since I can't reproduce it on my machine :-( ... any volunteer ?
Posted 1 year ago # -
Maybe nodes could have a flag we could set that told cocos to remove it safely whenever cocos iterates through it next. So we wouldnt remove sprites directly, but just mark them for removal and cocos handles it sometime before the next tick.
Posted 1 year ago # -
It seems you can remove an object during the iteration, at least you'll not get a crash, but I think it's not done correctly. But I am not sure...
Posted 1 year ago # -
Has anyone done performance testing on the bug fixed "CCARRAY_FOREACH" - seems to be slower - any thoughts?
Posted 1 year ago # -
http://www.learn-cocos2d.com/2011/11/depth-ios-cocos2d-performance-analysis-test-project/
Someone probably should look into insert.Posted 2 months ago # -
Posted 2 months ago #
-
The problem with insert at index 0 is definitely real for CCArray.
Do not worry if your array is small.// Test this loop for speed for the CCArray and NSMutableArray:
for(i=0;i<testCount;i++) { [test insertObject:obj atIndex:0]; }// Test results for iPod 1gen:
testCount = 100; Insert time is about 6 ms for both arrays (CCArray is slightly faster) testCount = 200; Insert time is about 13 ms for both arrays (CCArray is slightly slower) If your array is big than rethink your algorithms. Penalty is huge: testCount = 10000; NSMutableArray: insert time is about 85 ms CCArray: insert time is about 3553 ms <-- 3.5sec !!!! 3553/85 = 41.8Posted 2 months ago # -
Inserting at 0 index:
testCount = 10000; // size of the array NSMutableArray: insert time at index 0 is about 85 ms CCArray: insert time at index 0 is about 3553 ms <-- 3.5sec !!!! 3553/85 = 41.8I hope it can be easily optimized - I did not look deeper into it yet.
Posted 1 month ago #
Reply
You must log in to post.