Now I have one trouble for develope one iPhone app.
I need to compute 150 parts and draw it on canvas.
I have code like this:
for (int i=x1; i<=x2; i++) {
for (int j=y1; j<=y2; j++) {
x=[NSNumber numberWithInt:i];
y=[NSNumber numberWithInt:j];
BoxCache *box = [[cache objectForKey:x] objectForKey:y];
if (box) {
ret.count += [box.species count];
}
[x release];
[y release];
}
}
His execution tired ~5 secs (computing array 15×10), I would like to ask everyone, any ideas to reduce compute time or do that different.
Instead of a dictionary of dictionaries (which is really inefficient), I’d use a regular old C array and malloc the memory myself. I might wrap it in a class just to make the memory management rules clearer, but that’s about it.