optimisation and compatiblity tweaks

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@38524 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
rfm 2015-05-22 15:34:25 +00:00
parent 009ecb41d6
commit e619a410d3
3 changed files with 18 additions and 9 deletions

View file

@ -1,3 +1,10 @@
2015-05-22 Richard Frith-Macdonald <rfm@gnu.org>
* Source/NSString.m:
* Source/GSString.m:
Some optimisation. Fix -hasPrefix: and -hasSuffix: to use literal
search as on OSX.
2015-05-15 Richard Frith-Macdonald <rfm@gnu.org>
* Documentation/install.texi:

View file

@ -287,7 +287,7 @@ static id ValueForKey(NSObject *self, const char *key, unsigned size)
- (NSMutableSet*) mutableSetValueForKeyPath: (NSString*)aKey
{
NSRange r = [aKey rangeOfString: @"."];
NSRange r = [aKey rangeOfString: @"." options: NSLiteralSearch];
if (r.length == 0)
{
@ -309,7 +309,7 @@ static id ValueForKey(NSObject *self, const char *key, unsigned size)
- (NSMutableArray*) mutableArrayValueForKeyPath: (NSString*)aKey
{
NSRange r = [aKey rangeOfString: @"."];
NSRange r = [aKey rangeOfString: @"." options: NSLiteralSearch];
if (r.length == 0)
{
@ -373,7 +373,7 @@ static id ValueForKey(NSObject *self, const char *key, unsigned size)
- (void) setValue: (id)anObject forKeyPath: (NSString*)aKey
{
NSRange r = [aKey rangeOfString: @"."];
NSRange r = [aKey rangeOfString: @"." options: NSLiteralSearch];
#ifdef WANT_DEPRECATED_KVC_COMPAT
IMP o = [self methodForSelector: @selector(takeValue:forKeyPath:)];
@ -499,7 +499,7 @@ static id ValueForKey(NSObject *self, const char *key, unsigned size)
forKeyPath: (NSString*)aKey
error: (NSError**)anError
{
NSRange r = [aKey rangeOfString: @"."];
NSRange r = [aKey rangeOfString: @"." options: NSLiteralSearch];
if (r.length == 0)
{
@ -532,7 +532,7 @@ static id ValueForKey(NSObject *self, const char *key, unsigned size)
- (id) valueForKeyPath: (NSString*)aKey
{
NSRange r = [aKey rangeOfString: @"."];
NSRange r = [aKey rangeOfString: @"." options: NSLiteralSearch];
if (r.length == 0)
{
@ -858,7 +858,7 @@ static id ValueForKey(NSObject *self, const char *key, unsigned size)
- (void) takeValue: (id)anObject forKeyPath: (NSString*)aKey
{
NSRange r = [aKey rangeOfString: @"."];
NSRange r = [aKey rangeOfString: @"." options: NSLiteralSearch];
GSOnceMLog(@"This method is deprecated, use -setValue:forKeyPath:");
if (r.length == 0)

View file

@ -2532,7 +2532,7 @@ GSICUCollatorOpen(NSStringCompareOptions mask, NSLocale *locale)
}
- (NSUInteger) indexOfString: (NSString*)substring
fromIndex: (NSUInteger)index
fromIndex: (NSUInteger)index
{
NSRange range = {index, [self length] - index};
@ -2638,9 +2638,10 @@ static BOOL (*nbImp)(id, SEL, unichar) = 0;
- (BOOL) hasPrefix: (NSString*)aString
{
NSRange range = NSMakeRange(0, [self length]);
NSUInteger mask = NSLiteralSearch | NSAnchoredSearch;
range = [self rangeOfString: aString
options: NSAnchoredSearch
options: mask
range: range
locale: nil];
return (range.length > 0) ? YES : NO;
@ -2652,9 +2653,10 @@ static BOOL (*nbImp)(id, SEL, unichar) = 0;
- (BOOL) hasSuffix: (NSString*)aString
{
NSRange range = NSMakeRange(0, [self length]);
NSUInteger mask = NSLiteralSearch | NSAnchoredSearch | NSBackwardsSearch;
range = [self rangeOfString: aString
options: NSAnchoredSearch | NSBackwardsSearch
options: mask
range: range
locale: nil];
return (range.length > 0) ? YES : NO;