Which would be the preferred method? With the assuming that myInteger 99.99% of time will have a valid value and this method will get called very rapidly.
-(BOOL)validDate
{
NSUInteger myInteger = ...//method to obtain value;
if (myInteger != NSNotFound)
return YES;
return NO;
}
-(BOOL)validDate
{
NSUInteger myInteger = ...//method to obtain value;
if (myInteger == NSNotFound)
return NO;
return YES;
}
The preferred would be:
- (BOOL)validDate
{
NSUInteger myInteger = ...//method to obtain value;
return (myInteger != NSNotFound);
}
because it doesn't actually need to execute a branch.
Note that the difference will be imperceptibly small unless you are running this code a lot...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With