NSString
is a "duty free bridge" to CFStringRef
, so you can check the implementation at http://www.opensource.apple.com/source/CF/CF-744.19/CFString.c .
The corresponding functions are CFStringHasPrefix()
and CFStringHasSuffix()
, which call CFStringFindWithOptionsAndLocale()
without or with the kCFCompareBackwards
flag.
As I understand the code, this flag does not affect performance, only some loop variables are initialized differently.
(But the general “disclaimer” also applies here: you should profile your application and see if checking the prefix / suffix is a performance bottleneck. If not, choose which is more logical or easier to maintain.)
source share