Is there a faster way to compare two variables?

I have this piece of code where Shark tells me about this bottleneck:

CGFloat shortestDistance = (distanceA < distanceB) ? distanceA : distanceB;

all of these values ​​are CGFloat. Is there a faster way to find out which one is smaller and assign it to the shortest? Maybe even by reference instead of copying the value? How do I do this and how can I access this later?

btw is code that runs in a very compressed loop. about 60 times per second.

+3
source share
4 answers

, . iPhone , 16- ARM. . . " iPhone ".

alt text

+7

60 . , .

, ; , Shark , , ?

+10

distanceA distanceB ( ) ? , , . , ?

, (1) , ARMv6 (2) __builtin_fminf(distanceA, distanceB). ; 60 .

+3

From the memory of modern CPUs, there are from 6 to 9 pipelines, which is even more likely since I last checked. What you usually consider a heavy processor is actually very small as soon as the optimizer gets to it.

0
source

Source: https://habr.com/ru/post/1723629/


All Articles