What is actually faster? Simply creating a new ArrayList/ArrayCollection or re-using an existing one and remove its elements?
I’m developing for mobiles where performance is always an issue, so I’m after the fastest method.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
even faster is
mycollection.source = [];(as opposed tomycollection.source = new Array())Another option is to use linked lists and object pools. Object pools allow the objects to have their properties re-written instead of deleting an object and creating a new one. If you then keep them in a linked list instead of an array, looping through them is a lot faster. So if you just want to loop through a bunch of objects, go with linked lists, but if you need to do any sorting, then the array and vectors would be faster.
Another concern is memory use. not just for keeping applications running memory smaller, but the more objects you declare, the more work the garbage collector has to do when it comes time for clean-up.