I have this piece of code where Shark tells me it’s a performance bottleneck:
CGFloat shortestDistance = (distanceA < distanceB) ? distanceA : distanceB;
all these values are CGFloat. Is there a faster way to figure out which one is smaller and assign that to shortestDistance? Maybe even by reference instead of copying a value? How would I do that and how would I access that later?
btw, this is code executed in a very tight loop. about 60 times per second.
What your likely running into is the thumb/arm FPU issue. iPhone apps default to compiling to thumb, which is a 16 bit subset of the regular ARM expressions. When in thumb mode, floating point operations are done using integer routines. You can switch this off and increase your floating point performance. See “Break That Thumb For Best iPhone Performance“.