fastest in objC: IsEqualToString:@"" or length > 0?
- by Cœur
I'd like to know which one is fastest for testing a non-empty NSString for iOS 4.0+ (iPhone 3G).
Note: the strings to test will be 99% of the time from 2 to 100 chars length.
if ([foo length] > 0)
or
if ([foo isEqualToString:@""] == NO && foo != nil)
I think it depends if isEqualToString: compares the length first (and in that case first way is faster) or if isEqualToString: compares first character of strings first (and in that case second way might be faster).
ps: I already know isEqualToString: is faster than isEqual: which is itself faster than compare:.