I encounter a frequent situation and i never knows which implementation is the fastest:
if have to test in an NSString* pattern is not equal to several other NSStrings. Currently i'm balanced between these 2 implementations:
NSString* pattern = @"XXXXXXX";
if(![pattern isEqualToString:a] && ![pattern isEqualToString:b] && ![pattern isEqualToString:c] && ....)
[self doSomeWork];
and
NSSet* forbiddenStringsSet = [NSSet setWithObjects:a,b,c,.......,nil]; (can be STATICALLY SET, ONCE FOR ALL !!!! of course)
if(![forbiddenStringsSet containsObject:pattern])
[self doSomeWork];
Of course, it all depends on the number of strings to tests...
What is your opinion?
Is it possible to have a graph, something like the famous for() vs NSEnumerator ... ? i have no idea how to implement such a test
thanks!