foundation - NSString compare efficiency -
string compares can costly. there's statistic floating around says high percent of string compares can eliminated first comparing string sizes. i'm curious know whether nsstring compare: method takes consideration. know?
according sources here (which 1 implementation, others may act differently), compare
doesn't check length first, makes sense since it's not equality check. returns less-than/equal-to/greater-than return code, has check characters, if lengths same.
a pure isequal
-type method may able shortcut character checks if lengths different, compare
not have luxury.
it checks of length against zero, not comparisons of 2 lengths against each other.
Comments
Post a Comment