mirror of
https://github.com/gnustep/libs-base.git
synced 2025-06-02 17:41:05 +00:00
More optimisation
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@4236 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
6fab8e2010
commit
e45bba803d
3 changed files with 273 additions and 250 deletions
|
@ -2,10 +2,10 @@ Mon May 10 8:00:00 1999 Richard Frith-Macdonald <richard@brainstorm.co.uk>
|
||||||
|
|
||||||
* Source/NSString.m: ([-rangeOfComposedCharacterSequenceAtIndex:])
|
* Source/NSString.m: ([-rangeOfComposedCharacterSequenceAtIndex:])
|
||||||
optimised.
|
optimised.
|
||||||
* Source/NSGString.m ([-rangeOfComposedCharacterSequenceAtIndex:])
|
* Source/NSGString.m: ([-rangeOfComposedCharacterSequenceAtIndex:])
|
||||||
implemented.
|
|
||||||
* Source/NSGCString.m ([-rangeOfComposedCharacterSequenceAtIndex:])
|
|
||||||
implemented.
|
implemented.
|
||||||
|
* Source/NSGCString.m: ([-rangeOfComposedCharacterSequenceAtIndex:])
|
||||||
|
* Source/NSGSequence.m: various parts optimised.
|
||||||
* Source/include/NSThread.h: add gcontext ivar.
|
* Source/include/NSThread.h: add gcontext ivar.
|
||||||
|
|
||||||
Fri May 7 15:12:00 1999 Richard Frith-Macdonald <richard@brainstorm.co.uk>
|
Fri May 7 15:12:00 1999 Richard Frith-Macdonald <richard@brainstorm.co.uk>
|
||||||
|
|
|
@ -45,9 +45,104 @@
|
||||||
#include <base/NSGSequence.h>
|
#include <base/NSGSequence.h>
|
||||||
#include <base//Unicode.h>
|
#include <base//Unicode.h>
|
||||||
|
|
||||||
|
#define MAXDEC 18
|
||||||
|
|
||||||
|
static inline void gs_seq_decompose(unichar **buffer, unsigned *length)
|
||||||
|
{
|
||||||
|
unichar *spoint;
|
||||||
|
unichar *tpoint;
|
||||||
|
unichar *dpoint;
|
||||||
|
unsigned count = *length;
|
||||||
|
|
||||||
|
if (count)
|
||||||
|
{
|
||||||
|
unichar source[count*MAXDEC+1];
|
||||||
|
unichar target[count*MAXDEC+1];
|
||||||
|
unichar *chars = *buffer;
|
||||||
|
BOOL notdone = YES;
|
||||||
|
|
||||||
|
spoint = source;
|
||||||
|
tpoint = target;
|
||||||
|
memcpy(source, chars, 2*count);
|
||||||
|
source[count] = (unichar)(0);
|
||||||
|
|
||||||
|
while (notdone)
|
||||||
|
{
|
||||||
|
notdone = NO;
|
||||||
|
do
|
||||||
|
{
|
||||||
|
if (!(dpoint = uni_is_decomp(*spoint)))
|
||||||
|
*tpoint++ = *spoint;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
while (*dpoint)
|
||||||
|
*tpoint++ = *dpoint++;
|
||||||
|
notdone = YES;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
while (*spoint++);
|
||||||
|
|
||||||
|
*tpoint = (unichar)0; // *** maybe not needed
|
||||||
|
|
||||||
|
memcpy(source, target, 2*(count*MAXDEC+1));
|
||||||
|
|
||||||
|
tpoint = target;
|
||||||
|
spoint = source;
|
||||||
|
}
|
||||||
|
|
||||||
|
count = uslen(source);
|
||||||
|
OBJC_REALLOC(chars, unichar, count+1);
|
||||||
|
memcpy(chars, source, 2*(count+1));
|
||||||
|
chars[count] = (unichar)0;
|
||||||
|
*buffer = chars;
|
||||||
|
*length = count;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void gs_seq_order(unichar *chars, unsigned len)
|
||||||
|
{
|
||||||
|
if (len > 1)
|
||||||
|
{
|
||||||
|
BOOL notdone = YES;
|
||||||
|
|
||||||
|
while (notdone)
|
||||||
|
{
|
||||||
|
unichar *first = chars;
|
||||||
|
unichar *second = first + 1;
|
||||||
|
unsigned count;
|
||||||
|
|
||||||
|
notdone = NO;
|
||||||
|
for (count = 1; count < len; count++)
|
||||||
|
{
|
||||||
|
if (uni_cop(*second))
|
||||||
|
{
|
||||||
|
if (uni_cop(*first) > uni_cop(*second))
|
||||||
|
{
|
||||||
|
unichar tmp = *first;
|
||||||
|
|
||||||
|
*first = *second;
|
||||||
|
*second = tmp;
|
||||||
|
notdone = YES;
|
||||||
|
}
|
||||||
|
else if (uni_cop(*first) == uni_cop(*second))
|
||||||
|
{
|
||||||
|
if (*first > *second)
|
||||||
|
{
|
||||||
|
unichar tmp = *first;
|
||||||
|
|
||||||
|
*first = *second;
|
||||||
|
*second = tmp;
|
||||||
|
notdone = YES;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
first++;
|
||||||
|
second++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#define FALSE 0
|
|
||||||
#define TRUE 1
|
|
||||||
|
|
||||||
@implementation NSGSequence
|
@implementation NSGSequence
|
||||||
|
|
||||||
|
@ -66,30 +161,28 @@ static Class seqClass;
|
||||||
+ (NSGSequence*) sequenceWithString: (NSString*) aString
|
+ (NSGSequence*) sequenceWithString: (NSString*) aString
|
||||||
range: (NSRange)aRange
|
range: (NSRange)aRange
|
||||||
{
|
{
|
||||||
return [[[self alloc] initWithString: aString range: aRange]
|
return [[[self allocWithZone: NSDefaultMallocZone()]
|
||||||
autorelease];
|
initWithString: aString range: aRange] autorelease];
|
||||||
}
|
}
|
||||||
|
|
||||||
+ (NSGSequence*) sequenceWithSequence: (NSGSequence*) aSequence
|
+ (NSGSequence*) sequenceWithSequence: (NSGSequence*) aSequence
|
||||||
|
|
||||||
{
|
{
|
||||||
return [[[self alloc]
|
return [[[self allocWithZone: NSDefaultMallocZone()]
|
||||||
initWithSequence: aSequence]
|
initWithSequence: aSequence] autorelease];
|
||||||
autorelease];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
+ (NSGSequence*) sequenceWithCharacters: (unichar *) characters
|
+ (NSGSequence*) sequenceWithCharacters: (unichar *) characters
|
||||||
length: (int) len
|
length: (int) len
|
||||||
{
|
{
|
||||||
return [[[self alloc]
|
return [[[self allocWithZone: NSDefaultMallocZone()]
|
||||||
initWithCharacters: characters length: len]
|
initWithCharacters: characters length: len] autorelease];
|
||||||
autorelease];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
+ (NSGSequence*) sequenceWithCharactersNoCopy: (unichar *) characters
|
+ (NSGSequence*) sequenceWithCharactersNoCopy: (unichar *) characters
|
||||||
length: (int) len freeWhenDone: (BOOL) flag
|
length: (int) len freeWhenDone: (BOOL) flag
|
||||||
{
|
{
|
||||||
return [[[self alloc]
|
return [[[self allocWithZone: NSDefaultMallocZone()]
|
||||||
initWithCharactersNoCopy: characters length: len freeWhenDone: flag]
|
initWithCharactersNoCopy: characters length: len freeWhenDone: flag]
|
||||||
autorelease];
|
autorelease];
|
||||||
}
|
}
|
||||||
|
@ -118,21 +211,24 @@ static Class seqClass;
|
||||||
unichar *s;
|
unichar *s;
|
||||||
if (aRange.location > [string length])
|
if (aRange.location > [string length])
|
||||||
[NSException raise: NSRangeException format: @"Invalid location."];
|
[NSException raise: NSRangeException format: @"Invalid location."];
|
||||||
|
|
||||||
if (aRange.length > ([string length] - aRange.location))
|
if (aRange.length > ([string length] - aRange.location))
|
||||||
[NSException raise: NSRangeException format: @"Invalid location+length."];
|
[NSException raise: NSRangeException format: @"Invalid location+length."];
|
||||||
|
|
||||||
OBJC_MALLOC(s, unichar, aRange.length+1);
|
OBJC_MALLOC(s, unichar, aRange.length+1);
|
||||||
[string getCharacters: s range: aRange];
|
[string getCharacters: s range: aRange];
|
||||||
s[aRange.length] = (unichar)0;
|
s[aRange.length] = (unichar)0;
|
||||||
return [self initWithCharactersNoCopy:s length: aRange.length freeWhenDone:YES];
|
return [self initWithCharactersNoCopy: s
|
||||||
|
length: aRange.length
|
||||||
|
freeWhenDone: YES];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (id) initWithSequence: (NSGSequence*) aSequence
|
- (id) initWithSequence: (NSGSequence*) aSequence
|
||||||
{
|
{
|
||||||
unichar *s;
|
unichar *s;
|
||||||
int len=[aSequence length];
|
unsigned len = aSequence->_count;
|
||||||
|
|
||||||
OBJC_MALLOC(s, unichar, len+1);
|
OBJC_MALLOC(s, unichar, len+1);
|
||||||
[aSequence getCharacters:s];
|
memcpy(s, aSequence->_contents_chars, len);
|
||||||
s[len] = (unichar)0;
|
s[len] = (unichar)0;
|
||||||
return [self initWithCharactersNoCopy: s length: len freeWhenDone: YES];
|
return [self initWithCharactersNoCopy: s length: len freeWhenDone: YES];
|
||||||
}
|
}
|
||||||
|
@ -174,7 +270,7 @@ static Class seqClass;
|
||||||
|
|
||||||
- (unichar) characterAtIndex: (unsigned int)index
|
- (unichar) characterAtIndex: (unsigned int)index
|
||||||
{
|
{
|
||||||
if (index >= [self length])
|
if (index >= _count)
|
||||||
[NSException raise: NSRangeException
|
[NSException raise: NSRangeException
|
||||||
format: @"index greater than sequence length"];
|
format: @"index greater than sequence length"];
|
||||||
return _contents_chars[index];
|
return _contents_chars[index];
|
||||||
|
@ -182,7 +278,7 @@ static Class seqClass;
|
||||||
|
|
||||||
- (unichar) baseCharacter
|
- (unichar) baseCharacter
|
||||||
{
|
{
|
||||||
if(![self isNormalized])
|
if (!_normalized)
|
||||||
[self normalize];
|
[self normalize];
|
||||||
return _contents_chars[0];
|
return _contents_chars[0];
|
||||||
}
|
}
|
||||||
|
@ -193,26 +289,16 @@ static Class seqClass;
|
||||||
return _contents_chars[0];
|
return _contents_chars[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Inefficient. */
|
|
||||||
- (void) getCharacters: (unichar*)buffer
|
- (void) getCharacters: (unichar*)buffer
|
||||||
{
|
{
|
||||||
[self getCharacters:buffer range:((NSRange){0,[self length]})];
|
memcpy(buffer, _contents_chars, _count*2);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Inefficient. */
|
/* Inefficient. */
|
||||||
- (void) getCharacters: (unichar*)buffer
|
- (void) getCharacters: (unichar*)buffer
|
||||||
range: (NSRange)aRange
|
range: (NSRange)aRange
|
||||||
{
|
{
|
||||||
#if 0
|
|
||||||
int i;
|
|
||||||
for (i = 0; i < aRange.length; i++)
|
|
||||||
{
|
|
||||||
buffer[i] = [self characterAtIndex: aRange.location+i];
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
memcpy(buffer, &_contents_chars[aRange.location], aRange.length*2);
|
memcpy(buffer, &_contents_chars[aRange.location], aRange.length*2);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//for debuging
|
//for debuging
|
||||||
|
@ -228,108 +314,22 @@ static Class seqClass;
|
||||||
|
|
||||||
- (NSGSequence*) decompose
|
- (NSGSequence*) decompose
|
||||||
{
|
{
|
||||||
#define MAXDEC 18
|
gs_seq_decompose(&_contents_chars, &_count);
|
||||||
|
|
||||||
unichar *source;
|
|
||||||
unichar *target;
|
|
||||||
unichar *spoint;
|
|
||||||
unichar *tpoint;
|
|
||||||
unichar *dpoint;
|
|
||||||
BOOL notdone;
|
|
||||||
int len;
|
|
||||||
|
|
||||||
if (_count)
|
|
||||||
{
|
|
||||||
OBJC_MALLOC(source, unichar, _count*MAXDEC+1);
|
|
||||||
OBJC_MALLOC(target, unichar, _count*MAXDEC+1);
|
|
||||||
spoint = source;
|
|
||||||
tpoint = target;
|
|
||||||
memcpy(source, _contents_chars, 2*_count);
|
|
||||||
source[_count]=(unichar)(0);
|
|
||||||
do
|
|
||||||
{
|
|
||||||
notdone=FALSE;
|
|
||||||
do
|
|
||||||
{
|
|
||||||
if(!(dpoint=uni_is_decomp(*spoint)))
|
|
||||||
*tpoint++ = *spoint;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
while(*dpoint)
|
|
||||||
*tpoint++=*dpoint++;
|
|
||||||
notdone=TRUE;
|
|
||||||
}
|
|
||||||
} while(*spoint++);
|
|
||||||
|
|
||||||
*tpoint=(unichar)0; // *** maybe not needed
|
|
||||||
|
|
||||||
memcpy(source, target,2*(_count*MAXDEC+1));
|
|
||||||
|
|
||||||
tpoint = target;
|
|
||||||
spoint = source;
|
|
||||||
|
|
||||||
} while(notdone);
|
|
||||||
len = uslen(source);
|
|
||||||
OBJC_REALLOC(_contents_chars, unichar, len+1);
|
|
||||||
memcpy(_contents_chars,source,2*(len+1));
|
|
||||||
_contents_chars[len] = (unichar)0;
|
|
||||||
_count = len;
|
|
||||||
OBJC_FREE(target);
|
|
||||||
OBJC_FREE(source);
|
|
||||||
return self;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return self;
|
|
||||||
}
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSGSequence*) order
|
- (NSGSequence*) order
|
||||||
{
|
{
|
||||||
unichar *first,*second,tmp;
|
gs_seq_order(_contents_chars, _count);
|
||||||
int count,len;
|
|
||||||
BOOL notdone;
|
|
||||||
len=[self length];
|
|
||||||
|
|
||||||
if(len>1)
|
|
||||||
do
|
|
||||||
{
|
|
||||||
notdone=NO;
|
|
||||||
first=_contents_chars;
|
|
||||||
second=first+1;
|
|
||||||
for(count=1;count<len;count++)
|
|
||||||
{
|
|
||||||
if(uni_cop(*second))
|
|
||||||
{
|
|
||||||
if(uni_cop(*first)>uni_cop(*second))
|
|
||||||
{
|
|
||||||
tmp= *first;
|
|
||||||
*first= *second;
|
|
||||||
*second=tmp;
|
|
||||||
notdone=YES;
|
|
||||||
}
|
|
||||||
if(uni_cop(*first)==uni_cop(*second))
|
|
||||||
if(*first>*second)
|
|
||||||
{
|
|
||||||
tmp= *first;
|
|
||||||
*first= *second;
|
|
||||||
*second=tmp;
|
|
||||||
notdone=YES;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
first++;
|
|
||||||
second++;
|
|
||||||
}
|
|
||||||
} while(notdone);
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSGSequence*) normalize
|
- (NSGSequence*) normalize
|
||||||
{
|
{
|
||||||
if(![self isNormalized])
|
if (!_normalized)
|
||||||
{
|
{
|
||||||
[[self decompose] order];
|
gs_seq_decompose(&_contents_chars, &_count);
|
||||||
|
gs_seq_order(_contents_chars, _count);
|
||||||
_normalized = YES;
|
_normalized = YES;
|
||||||
}
|
}
|
||||||
return self;
|
return self;
|
||||||
|
@ -350,7 +350,7 @@ static Class seqClass;
|
||||||
if (uni_is_decomp(_contents_chars[0]))
|
if (uni_is_decomp(_contents_chars[0]))
|
||||||
return YES;
|
return YES;
|
||||||
else
|
else
|
||||||
if([self length]<2)
|
if (_count < 2)
|
||||||
return NO;
|
return NO;
|
||||||
else
|
else
|
||||||
return YES;
|
return YES;
|
||||||
|
@ -365,25 +365,31 @@ static Class seqClass;
|
||||||
- (NSGSequence*) lowercase
|
- (NSGSequence*) lowercase
|
||||||
{
|
{
|
||||||
unichar *s;
|
unichar *s;
|
||||||
int count;
|
unsigned count;
|
||||||
int len=[self length];
|
unsigned len = _count;
|
||||||
|
|
||||||
OBJC_MALLOC(s, unichar, len + 1);
|
OBJC_MALLOC(s, unichar, len + 1);
|
||||||
for (count =0; count < len; count++)
|
for (count =0; count < len; count++)
|
||||||
s[count] = uni_tolower(_contents_chars[count]);
|
s[count] = uni_tolower(_contents_chars[count]);
|
||||||
s[len] = (unichar)0;
|
s[len] = (unichar)0;
|
||||||
return [seqClass sequenceWithCharactersNoCopy:s length:len freeWhenDone:YES];
|
return [seqClass sequenceWithCharactersNoCopy: s
|
||||||
|
length: len
|
||||||
|
freeWhenDone: YES];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSGSequence*) uppercase
|
- (NSGSequence*) uppercase
|
||||||
{
|
{
|
||||||
unichar *s;
|
unichar *s;
|
||||||
int count;
|
unsigned count;
|
||||||
int len=[self length];
|
unsigned len = _count;
|
||||||
|
|
||||||
OBJC_MALLOC(s, unichar, len + 1);
|
OBJC_MALLOC(s, unichar, len + 1);
|
||||||
for (count = 0; count < len; count++)
|
for (count = 0; count < len; count++)
|
||||||
s[count] = uni_toupper(_contents_chars[count]);
|
s[count] = uni_toupper(_contents_chars[count]);
|
||||||
s[len] = (unichar)0;
|
s[len] = (unichar)0;
|
||||||
return [seqClass sequenceWithCharactersNoCopy:s length:len freeWhenDone:YES];
|
return [seqClass sequenceWithCharactersNoCopy: s
|
||||||
|
length: len
|
||||||
|
freeWhenDone: YES];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSGSequence*) titlecase
|
- (NSGSequence*) titlecase
|
||||||
|
@ -392,34 +398,37 @@ static Class seqClass;
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Inefficient */
|
|
||||||
- (NSComparisonResult) compare: (NSGSequence*) aSequence
|
- (NSComparisonResult) compare: (NSGSequence*) aSequence
|
||||||
{
|
{
|
||||||
int i,end;
|
unsigned i;
|
||||||
unsigned int myLength;
|
unsigned end;
|
||||||
unsigned int seqLength;
|
unsigned myLength;
|
||||||
|
unsigned seqLength;
|
||||||
|
|
||||||
if(![self isNormalized])
|
if (!_normalized)
|
||||||
[self normalize];
|
{
|
||||||
if(![aSequence isNormalized])
|
gs_seq_decompose(&_contents_chars, &_count);
|
||||||
[aSequence normalize];
|
gs_seq_order(_contents_chars, _count);
|
||||||
myLength = [self length];
|
_normalized = YES;
|
||||||
seqLength = [aSequence length];
|
}
|
||||||
|
if (!aSequence->_normalized)
|
||||||
|
{
|
||||||
|
gs_seq_decompose(&aSequence->_contents_chars, &aSequence->_count);
|
||||||
|
gs_seq_order(aSequence->_contents_chars, aSequence->_count);
|
||||||
|
_normalized = YES;
|
||||||
|
}
|
||||||
|
myLength = _count;
|
||||||
|
seqLength = aSequence->_count;
|
||||||
if (myLength < seqLength)
|
if (myLength < seqLength)
|
||||||
end = myLength;
|
end = myLength;
|
||||||
else
|
else
|
||||||
end = seqLength;
|
end = seqLength;
|
||||||
for (i = 0; i < end; i ++)
|
for (i = 0; i < end; i ++)
|
||||||
{
|
{
|
||||||
#if 0
|
|
||||||
if ([self characterAtIndex:i] < [aSequence characterAtIndex:i]) return NSOrderedAscending;
|
|
||||||
if ([self characterAtIndex:i] > [aSequence characterAtIndex:i]) return NSOrderedDescending;
|
|
||||||
#else
|
|
||||||
if (_contents_chars[i] < aSequence->_contents_chars[i])
|
if (_contents_chars[i] < aSequence->_contents_chars[i])
|
||||||
return NSOrderedAscending;
|
return NSOrderedAscending;
|
||||||
if (_contents_chars[i] > aSequence->_contents_chars[i])
|
if (_contents_chars[i] > aSequence->_contents_chars[i])
|
||||||
return NSOrderedDescending;
|
return NSOrderedDescending;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
if (myLength < seqLength)
|
if (myLength < seqLength)
|
||||||
return NSOrderedAscending;
|
return NSOrderedAscending;
|
||||||
|
|
|
@ -100,6 +100,9 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
static Class NSString_class; /* For speed */
|
static Class NSString_class; /* For speed */
|
||||||
|
static Class NSGSequence_class; /* For speed */
|
||||||
|
|
||||||
|
static SEL caiSel = @selector(characterAtIndex:);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Include property-list parsing code configured for unicode characters.
|
* Include property-list parsing code configured for unicode characters.
|
||||||
|
@ -250,6 +253,7 @@ handle_printf_atsign (FILE *stream,
|
||||||
{
|
{
|
||||||
_DefaultStringEncoding = GetDefEncoding();
|
_DefaultStringEncoding = GetDefEncoding();
|
||||||
NSString_class = self;
|
NSString_class = self;
|
||||||
|
NSGSequence_class = [NSGSequence class];
|
||||||
NSString_concrete_class = [NSGString class];
|
NSString_concrete_class = [NSGString class];
|
||||||
NSString_c_concrete_class = [NSGCString class];
|
NSString_c_concrete_class = [NSGCString class];
|
||||||
NSMutableString_concrete_class = [NSGMutableString class];
|
NSMutableString_concrete_class = [NSGMutableString class];
|
||||||
|
@ -1016,7 +1020,7 @@ handle_printf_atsign (FILE *stream,
|
||||||
if (mask & NSAnchoredSearch)
|
if (mask & NSAnchoredSearch)
|
||||||
myEndIndex = myIndex;
|
myEndIndex = myIndex;
|
||||||
|
|
||||||
strFirstCharacterSeq = [NSGSequence sequenceWithString: aString
|
strFirstCharacterSeq = [NSGSequence_class sequenceWithString: aString
|
||||||
range: [aString rangeOfComposedCharacterSequenceAtIndex: 0]];
|
range: [aString rangeOfComposedCharacterSequenceAtIndex: 0]];
|
||||||
|
|
||||||
for (;;)
|
for (;;)
|
||||||
|
@ -1026,7 +1030,7 @@ handle_printf_atsign (FILE *stream,
|
||||||
NSRange strRange;
|
NSRange strRange;
|
||||||
unsigned int myCount = 1;
|
unsigned int myCount = 1;
|
||||||
unsigned int strCount = 1;
|
unsigned int strCount = 1;
|
||||||
id myCharacter = [NSGSequence sequenceWithString: self
|
id myCharacter = [NSGSequence_class sequenceWithString: self
|
||||||
range: [self rangeOfComposedCharacterSequenceAtIndex: myIndex]];
|
range: [self rangeOfComposedCharacterSequenceAtIndex: myIndex]];
|
||||||
id strCharacter = strFirstCharacterSeq;
|
id strCharacter = strFirstCharacterSeq;
|
||||||
for (;;)
|
for (;;)
|
||||||
|
@ -1038,9 +1042,9 @@ handle_printf_atsign (FILE *stream,
|
||||||
if (strCount >= strLength)
|
if (strCount >= strLength)
|
||||||
return (NSRange){myIndex, myCount};
|
return (NSRange){myIndex, myCount};
|
||||||
myRange = [self rangeOfComposedCharacterSequenceAtIndex: myIndex + myCount];
|
myRange = [self rangeOfComposedCharacterSequenceAtIndex: myIndex + myCount];
|
||||||
myCharacter = [NSGSequence sequenceWithString: self range: myRange];
|
myCharacter = [NSGSequence_class sequenceWithString: self range: myRange];
|
||||||
strRange = [aString rangeOfComposedCharacterSequenceAtIndex: strCount];
|
strRange = [aString rangeOfComposedCharacterSequenceAtIndex: strCount];
|
||||||
strCharacter = [NSGSequence sequenceWithString: aString range: strRange];
|
strCharacter = [NSGSequence_class sequenceWithString: aString range: strRange];
|
||||||
myCount += myRange.length;
|
myCount += myRange.length;
|
||||||
strCount += strRange.length;
|
strCount += strRange.length;
|
||||||
} /* for */
|
} /* for */
|
||||||
|
@ -1069,7 +1073,7 @@ handle_printf_atsign (FILE *stream,
|
||||||
if (mask & NSAnchoredSearch)
|
if (mask & NSAnchoredSearch)
|
||||||
myEndIndex = myIndex;
|
myEndIndex = myIndex;
|
||||||
|
|
||||||
strFirstCharacterSeq = [NSGSequence sequenceWithString: aString
|
strFirstCharacterSeq = [NSGSequence_class sequenceWithString: aString
|
||||||
range: [aString rangeOfComposedCharacterSequenceAtIndex: 0]];
|
range: [aString rangeOfComposedCharacterSequenceAtIndex: 0]];
|
||||||
|
|
||||||
for (;;)
|
for (;;)
|
||||||
|
@ -1078,7 +1082,7 @@ handle_printf_atsign (FILE *stream,
|
||||||
NSRange strRange;
|
NSRange strRange;
|
||||||
unsigned int myCount = 1;
|
unsigned int myCount = 1;
|
||||||
unsigned int strCount = 1;
|
unsigned int strCount = 1;
|
||||||
id myCharacter = [NSGSequence sequenceWithString: self
|
id myCharacter = [NSGSequence_class sequenceWithString: self
|
||||||
range: [self rangeOfComposedCharacterSequenceAtIndex: myIndex]];
|
range: [self rangeOfComposedCharacterSequenceAtIndex: myIndex]];
|
||||||
id strCharacter = strFirstCharacterSeq;
|
id strCharacter = strFirstCharacterSeq;
|
||||||
for (;;)
|
for (;;)
|
||||||
|
@ -1089,9 +1093,9 @@ handle_printf_atsign (FILE *stream,
|
||||||
break;
|
break;
|
||||||
if (strCount >= strLength)
|
if (strCount >= strLength)
|
||||||
return (NSRange){myIndex, myCount};
|
return (NSRange){myIndex, myCount};
|
||||||
myCharacter = [NSGSequence sequenceWithString: self range: [self rangeOfComposedCharacterSequenceAtIndex: myIndex + myCount]];
|
myCharacter = [NSGSequence_class sequenceWithString: self range: [self rangeOfComposedCharacterSequenceAtIndex: myIndex + myCount]];
|
||||||
myRange = [self rangeOfComposedCharacterSequenceAtIndex: myIndex + myCount];
|
myRange = [self rangeOfComposedCharacterSequenceAtIndex: myIndex + myCount];
|
||||||
strCharacter = [NSGSequence sequenceWithString: aString range: [aString rangeOfComposedCharacterSequenceAtIndex: strCount]];
|
strCharacter = [NSGSequence_class sequenceWithString: aString range: [aString rangeOfComposedCharacterSequenceAtIndex: strCount]];
|
||||||
strRange = [aString rangeOfComposedCharacterSequenceAtIndex: strCount];
|
strRange = [aString rangeOfComposedCharacterSequenceAtIndex: strCount];
|
||||||
myCount += myRange.length;
|
myCount += myRange.length;
|
||||||
strCount += strRange.length;
|
strCount += strRange.length;
|
||||||
|
@ -1123,7 +1127,7 @@ handle_printf_atsign (FILE *stream,
|
||||||
if (mask & NSAnchoredSearch)
|
if (mask & NSAnchoredSearch)
|
||||||
myEndIndex = myIndex;
|
myEndIndex = myIndex;
|
||||||
|
|
||||||
strFirstCharacterSeq = [NSGSequence sequenceWithString: aString
|
strFirstCharacterSeq = [NSGSequence_class sequenceWithString: aString
|
||||||
range: [aString rangeOfComposedCharacterSequenceAtIndex: 0]];
|
range: [aString rangeOfComposedCharacterSequenceAtIndex: 0]];
|
||||||
|
|
||||||
for (;;)
|
for (;;)
|
||||||
|
@ -1133,7 +1137,7 @@ handle_printf_atsign (FILE *stream,
|
||||||
NSRange mainRange;
|
NSRange mainRange;
|
||||||
unsigned int myCount = 1;
|
unsigned int myCount = 1;
|
||||||
unsigned int strCount = 1;
|
unsigned int strCount = 1;
|
||||||
id myCharacter = [NSGSequence sequenceWithString: self
|
id myCharacter = [NSGSequence_class sequenceWithString: self
|
||||||
range: [self rangeOfComposedCharacterSequenceAtIndex: myIndex]];
|
range: [self rangeOfComposedCharacterSequenceAtIndex: myIndex]];
|
||||||
id strCharacter = strFirstCharacterSeq;
|
id strCharacter = strFirstCharacterSeq;
|
||||||
for (;;)
|
for (;;)
|
||||||
|
@ -1143,9 +1147,9 @@ handle_printf_atsign (FILE *stream,
|
||||||
if (strCount >= strLength)
|
if (strCount >= strLength)
|
||||||
return (NSRange){myIndex, myCount};
|
return (NSRange){myIndex, myCount};
|
||||||
myRange = [self rangeOfComposedCharacterSequenceAtIndex: myIndex + myCount];
|
myRange = [self rangeOfComposedCharacterSequenceAtIndex: myIndex + myCount];
|
||||||
myCharacter = [NSGSequence sequenceWithString: self range: myRange];
|
myCharacter = [NSGSequence_class sequenceWithString: self range: myRange];
|
||||||
strRange = [aString rangeOfComposedCharacterSequenceAtIndex: strCount];
|
strRange = [aString rangeOfComposedCharacterSequenceAtIndex: strCount];
|
||||||
strCharacter = [NSGSequence sequenceWithString: aString range: strRange];
|
strCharacter = [NSGSequence_class sequenceWithString: aString range: strRange];
|
||||||
myCount += myRange.length;
|
myCount += myRange.length;
|
||||||
strCount += strRange.length;
|
strCount += strRange.length;
|
||||||
} /* for */
|
} /* for */
|
||||||
|
@ -1175,7 +1179,7 @@ handle_printf_atsign (FILE *stream,
|
||||||
if (mask & NSAnchoredSearch)
|
if (mask & NSAnchoredSearch)
|
||||||
myEndIndex = myIndex;
|
myEndIndex = myIndex;
|
||||||
|
|
||||||
strFirstCharacterSeq = [NSGSequence sequenceWithString: aString
|
strFirstCharacterSeq = [NSGSequence_class sequenceWithString: aString
|
||||||
range: [aString rangeOfComposedCharacterSequenceAtIndex: 0]];
|
range: [aString rangeOfComposedCharacterSequenceAtIndex: 0]];
|
||||||
|
|
||||||
for (;;)
|
for (;;)
|
||||||
|
@ -1184,7 +1188,7 @@ handle_printf_atsign (FILE *stream,
|
||||||
NSRange strRange;
|
NSRange strRange;
|
||||||
unsigned int myCount = 1;
|
unsigned int myCount = 1;
|
||||||
unsigned int strCount = 1;
|
unsigned int strCount = 1;
|
||||||
id myCharacter = [NSGSequence sequenceWithString: self
|
id myCharacter = [NSGSequence_class sequenceWithString: self
|
||||||
range: [self rangeOfComposedCharacterSequenceAtIndex: myIndex]];
|
range: [self rangeOfComposedCharacterSequenceAtIndex: myIndex]];
|
||||||
id strCharacter = strFirstCharacterSeq;
|
id strCharacter = strFirstCharacterSeq;
|
||||||
for (;;)
|
for (;;)
|
||||||
|
@ -1194,9 +1198,9 @@ handle_printf_atsign (FILE *stream,
|
||||||
break;
|
break;
|
||||||
if (strCount >= strLength)
|
if (strCount >= strLength)
|
||||||
return (NSRange){myIndex, myCount};
|
return (NSRange){myIndex, myCount};
|
||||||
myCharacter = [NSGSequence sequenceWithString: self range: [self rangeOfComposedCharacterSequenceAtIndex: myIndex + myCount]];
|
myCharacter = [NSGSequence_class sequenceWithString: self range: [self rangeOfComposedCharacterSequenceAtIndex: myIndex + myCount]];
|
||||||
myRange = [self rangeOfComposedCharacterSequenceAtIndex: myIndex + myCount];
|
myRange = [self rangeOfComposedCharacterSequenceAtIndex: myIndex + myCount];
|
||||||
strCharacter = [NSGSequence sequenceWithString: aString range: [aString rangeOfComposedCharacterSequenceAtIndex: strCount]];
|
strCharacter = [NSGSequence_class sequenceWithString: aString range: [aString rangeOfComposedCharacterSequenceAtIndex: strCount]];
|
||||||
strRange = [aString rangeOfComposedCharacterSequenceAtIndex: strCount];
|
strRange = [aString rangeOfComposedCharacterSequenceAtIndex: strCount];
|
||||||
myCount += myRange.length;
|
myCount += myRange.length;
|
||||||
strCount += strRange.length;
|
strCount += strRange.length;
|
||||||
|
@ -1425,8 +1429,8 @@ else
|
||||||
myCount += myRange.length;
|
myCount += myRange.length;
|
||||||
strRange = [aString rangeOfComposedCharacterSequenceAtIndex: strCount];
|
strRange = [aString rangeOfComposedCharacterSequenceAtIndex: strCount];
|
||||||
strCount += strRange.length;
|
strCount += strRange.length;
|
||||||
mySeq = [NSGSequence sequenceWithString: self range: myRange];
|
mySeq = [NSGSequence_class sequenceWithString: self range: myRange];
|
||||||
strSeq = [NSGSequence sequenceWithString: aString range: strRange];
|
strSeq = [NSGSequence_class sequenceWithString: aString range: strRange];
|
||||||
if (mask & NSCaseInsensitiveSearch)
|
if (mask & NSCaseInsensitiveSearch)
|
||||||
result = [[mySeq lowercase] compare: [strSeq lowercase]];
|
result = [[mySeq lowercase] compare: [strSeq lowercase]];
|
||||||
else
|
else
|
||||||
|
@ -1473,12 +1477,19 @@ else
|
||||||
|
|
||||||
- (BOOL) isEqualToString: (NSString*)aString
|
- (BOOL) isEqualToString: (NSString*)aString
|
||||||
{
|
{
|
||||||
id mySeq, strSeq;
|
id mySeq;
|
||||||
NSRange myRange, strRange;
|
id strSeq;
|
||||||
unsigned int myLength;
|
NSRange myRange;
|
||||||
unsigned int strLength;
|
NSRange strRange;
|
||||||
unsigned int myIndex = 0;
|
unsigned myLength;
|
||||||
unsigned int strIndex = 0;
|
unsigned strLength;
|
||||||
|
unsigned myIndex = 0;
|
||||||
|
unsigned strIndex = 0;
|
||||||
|
static SEL ranSel = @selector(rangeOfComposedCharacterSequenceAtIndex:);
|
||||||
|
unichar (*scImp)(NSString*, SEL, unsigned);
|
||||||
|
unichar (*ocImp)(NSString*, SEL, unsigned);
|
||||||
|
NSRange (*srImp)(NSString*, SEL, unsigned);
|
||||||
|
NSRange (*orImp)(NSString*, SEL, unsigned);
|
||||||
|
|
||||||
if ([self hash] != [aString hash])
|
if ([self hash] != [aString hash])
|
||||||
return NO;
|
return NO;
|
||||||
|
@ -1491,23 +1502,27 @@ else
|
||||||
if (!strLength)
|
if (!strLength)
|
||||||
return NO;
|
return NO;
|
||||||
|
|
||||||
|
scImp = (unichar (*)())[self methodForSelector: caiSel];
|
||||||
|
ocImp = (unichar (*)())[aString methodForSelector: caiSel];
|
||||||
|
srImp = (NSRange (*)())[self methodForSelector: ranSel];
|
||||||
|
orImp = (NSRange (*)())[aString methodForSelector: ranSel];
|
||||||
|
|
||||||
while ((myIndex < myLength) && (strIndex < strLength))
|
while ((myIndex < myLength) && (strIndex < strLength))
|
||||||
if ([self characterAtIndex: myIndex] ==
|
if ((*scImp)(self, caiSel, myIndex) == (*ocImp)(aString, caiSel, strIndex))
|
||||||
[aString characterAtIndex: strIndex])
|
|
||||||
{
|
{
|
||||||
myIndex++;
|
myIndex++;
|
||||||
strIndex++;
|
strIndex++;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
myRange = [self rangeOfComposedCharacterSequenceAtIndex: myIndex];
|
myRange = (*srImp)(self, ranSel, myIndex);
|
||||||
strRange = [aString rangeOfComposedCharacterSequenceAtIndex: strIndex];
|
strRange = (*orImp)(aString, ranSel, strIndex);
|
||||||
if ((myRange.length < 2) || (strRange.length < 2))
|
if ((myRange.length < 2) || (strRange.length < 2))
|
||||||
return NO;
|
return NO;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
mySeq = [NSGSequence sequenceWithString: self range: myRange];
|
mySeq = [NSGSequence_class sequenceWithString: self range: myRange];
|
||||||
strSeq = [NSGSequence sequenceWithString: aString range: strRange];
|
strSeq = [NSGSequence_class sequenceWithString: aString range: strRange];
|
||||||
if ([mySeq isEqual: strSeq])
|
if ([mySeq isEqual: strSeq])
|
||||||
{
|
{
|
||||||
myIndex += myRange.length;
|
myIndex += myRange.length;
|
||||||
|
@ -1707,8 +1722,8 @@ else
|
||||||
return [self substringFromRange: NSMakeRange(0, myIndex)];
|
return [self substringFromRange: NSMakeRange(0, myIndex)];
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
mySeq = [NSGSequence sequenceWithString: self range: myRange];
|
mySeq = [NSGSequence_class sequenceWithString: self range: myRange];
|
||||||
strSeq = [NSGSequence sequenceWithString: aString range: strRange];
|
strSeq = [NSGSequence_class sequenceWithString: aString range: strRange];
|
||||||
if ([[mySeq lowercase] isEqual: [strSeq lowercase]])
|
if ([[mySeq lowercase] isEqual: [strSeq lowercase]])
|
||||||
{
|
{
|
||||||
myIndex += myRange.length;
|
myIndex += myRange.length;
|
||||||
|
@ -1737,8 +1752,8 @@ else
|
||||||
return [self substringFromRange: NSMakeRange(0, myIndex)];
|
return [self substringFromRange: NSMakeRange(0, myIndex)];
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
mySeq = [NSGSequence sequenceWithString: self range: myRange];
|
mySeq = [NSGSequence_class sequenceWithString: self range: myRange];
|
||||||
strSeq = [NSGSequence sequenceWithString: aString range: strRange];
|
strSeq = [NSGSequence_class sequenceWithString: aString range: strRange];
|
||||||
if ([mySeq isEqual: strSeq])
|
if ([mySeq isEqual: strSeq])
|
||||||
{
|
{
|
||||||
myIndex += myRange.length;
|
myIndex += myRange.length;
|
||||||
|
@ -2566,7 +2581,6 @@ else
|
||||||
if (len > 0)
|
if (len > 0)
|
||||||
{
|
{
|
||||||
int count = 0;
|
int count = 0;
|
||||||
SEL caiSel = @selector(characterAtIndex: );
|
|
||||||
unichar (*caiImp)() = (unichar (*)())[self methodForSelector: caiSel];
|
unichar (*caiImp)() = (unichar (*)())[self methodForSelector: caiSel];
|
||||||
|
|
||||||
while (count < len)
|
while (count < len)
|
||||||
|
@ -2594,7 +2608,7 @@ else
|
||||||
while (count < len)
|
while (count < len)
|
||||||
{
|
{
|
||||||
r = [self rangeOfComposedCharacterSequenceAtIndex: count];
|
r = [self rangeOfComposedCharacterSequenceAtIndex: count];
|
||||||
seq=[NSGSequence sequenceWithString: self range: r];
|
seq=[NSGSequence_class sequenceWithString: self range: r];
|
||||||
[[seq normalize] getCharacters: upoint];
|
[[seq normalize] getCharacters: upoint];
|
||||||
upoint += [seq length];
|
upoint += [seq length];
|
||||||
count += r.length;
|
count += r.length;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue