Which one of these will produce the most efficient/smaller binary code?
THIS
int sum = 0;
for (NSNumber * oneObj in objArray) {
if ([oneObj intValue] > 10)
sum += [oneObj intValue];
else
sum -= [oneObj intValue];
}
OR THIS?
int sum = 0;
for (NSNumber * oneObj in objArray) {
sum += ([oneObj intValue] > 10) ? oneObj : -oneObj;
}
does it make any difference writing the IF in this condensed form?
The compiled versions will be identical.
It’s two different ways of expressing the same thing