Skip to main content
AI Assist is now on Stack Overflow. Start a chat to get instant answers from across the network. Sign up to save and share your chats.
6 events
when toggle format what by license comment
Jul 27, 2011 at 4:12 comment added user427390 Thanks-- I think I should go with that.
Jul 27, 2011 at 4:07 comment added jkraybill Not if doing that is a) cheap and b) helps make your mobile app run faster. Lots of protocols (e.g. HTTP) use such a mechanism.
Jul 27, 2011 at 2:55 comment added user427390 I can't know the exact size in advance but I can get a general idea depending on which activity is using class-- I know roughly if the file will be large or small. I may be able to add in a default size parameter to the constructor and give an educated guess when I instantiate the object. edit: I suppose I could tack the size of the file on the first line of the file.. that feels sloppy though-- looked down upon?
Jul 27, 2011 at 2:28 comment added jkraybill Ah, well in that case, optimize the living phooey out of it. For most classes of usage, though, ArrayList doesn't incur much more overhead than a raw array (when properly sized); the logic that deals with the many strings is quite possibly a better candidate for optimization. Watch out for the default re-sizing strategy AL uses, though; if your code can't know in advance the numbers of elements it's dealing with, you may be better rolling your own re-sizing strategy. There are also other optimizations you can use if the list is read-only, like not resizing at all but just creating a 2nd array.
Jul 27, 2011 at 2:20 comment added user427390 Actually, this is for Android. I have a working application and I have entered a 'refactor and optimize' stage. I didn't tag the problem as an Android problem because I thought it's pretty general but the fact it's for mobile seems like it could sway opinions. Nice post~ has me thinking a lot
Jul 27, 2011 at 2:03 history answered jkraybill CC BY-SA 3.0