Some more performance tweaks for replagins strings in a mutable string.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@26785 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-MacDonald 2008-07-15 07:58:49 +00:00
parent b3464c3c03
commit 4c288ca2dd
3 changed files with 54 additions and 11 deletions

View file

@ -2536,11 +2536,6 @@ rangeOfString_c(GSStr self, NSString *aString, unsigned mask, NSRange aRange)
{
Class c;
if (aString == nil)
[NSException raise: NSInvalidArgumentException format: @"range of nil"];
if (GSObjCIsInstance(aString) == NO)
return strRangeCsNs((id)self, aString, mask, aRange);
c = GSObjCClass(aString);
if (GSObjCIsKindOf(c, GSUnicodeStringClass) == YES
|| (c == GSMutableStringClass && ((GSStr)aString)->_flags.wide == 1))
@ -2558,11 +2553,6 @@ rangeOfString_u(GSStr self, NSString *aString, unsigned mask, NSRange aRange)
{
Class c;
if (aString == nil)
[NSException raise: NSInvalidArgumentException format: @"range of nil"];
if (GSObjCIsInstance(aString) == NO)
return strRangeUsNs((id)self, aString, mask, aRange);
c = GSObjCClass(aString);
if (GSObjCIsKindOf(c, GSUnicodeStringClass) == YES
|| (c == GSMutableStringClass && ((GSStr)aString)->_flags.wide == 1))
@ -3016,6 +3006,15 @@ transmute(GSStr self, NSString *aString)
options: (unsigned)mask
range: (NSRange)aRange
{
GS_RANGE_CHECK(aRange, _count);
if (aString == nil)
[NSException raise: NSInvalidArgumentException
format: @"[%@ -%@] nil string argument",
NSStringFromClass([self class]), NSStringFromSelector(_cmd)];
if (GSObjCIsInstance(aString) == NO)
[NSException raise: NSInvalidArgumentException
format: @"[%@ -%@] not a string argument",
NSStringFromClass([self class]), NSStringFromSelector(_cmd)];
return rangeOfString_c((GSStr)self, aString, mask, aRange);
}
@ -3329,6 +3328,15 @@ agree, create a new GSCInlineString otherwise.
options: (unsigned)mask
range: (NSRange)aRange
{
GS_RANGE_CHECK(aRange, _count);
if (aString == nil)
[NSException raise: NSInvalidArgumentException
format: @"[%@ -%@] nil string argument",
NSStringFromClass([self class]), NSStringFromSelector(_cmd)];
if (GSObjCIsInstance(aString) == NO)
[NSException raise: NSInvalidArgumentException
format: @"[%@ -%@] not a string argument",
NSStringFromClass([self class]), NSStringFromSelector(_cmd)];
return rangeOfString_u((GSStr)self, aString, mask, aRange);
}
@ -4127,6 +4135,15 @@ NSAssert(_flags.free == 1 && _zone != 0, NSInternalInconsistencyException);
options: (unsigned)mask
range: (NSRange)aRange
{
GS_RANGE_CHECK(aRange, _count);
if (aString == nil)
[NSException raise: NSInvalidArgumentException
format: @"[%@ -%@] nil string argument",
NSStringFromClass([self class]), NSStringFromSelector(_cmd)];
if (GSObjCIsInstance(aString) == NO)
[NSException raise: NSInvalidArgumentException
format: @"[%@ -%@] not a string argument",
NSStringFromClass([self class]), NSStringFromSelector(_cmd)];
if (_flags.wide == 1)
return rangeOfString_u((GSStr)self, aString, mask, aRange);
else
@ -4590,6 +4607,7 @@ NSAssert(_flags.free == 1 && _zone != 0, NSInternalInconsistencyException);
options: (unsigned)mask
range: (NSRange)aRange
{
GS_RANGE_CHECK(aRange, ((GSStr)_parent)->_count);
return [_parent rangeOfCharacterFromSet: aSet options: mask range: aRange];
}
@ -4597,6 +4615,15 @@ NSAssert(_flags.free == 1 && _zone != 0, NSInternalInconsistencyException);
options: (unsigned)mask
range: (NSRange)aRange
{
GS_RANGE_CHECK(aRange, ((GSStr)_parent)->_count);
if (aString == nil)
[NSException raise: NSInvalidArgumentException
format: @"[%@ -%@] nil string argument",
NSStringFromClass([self class]), NSStringFromSelector(_cmd)];
if (GSObjCIsInstance(aString) == NO)
[NSException raise: NSInvalidArgumentException
format: @"[%@ -%@] not a string argument",
NSStringFromClass([self class]), NSStringFromSelector(_cmd)];
return [_parent rangeOfString: aString options: mask range: aRange];
}
@ -4788,6 +4815,15 @@ NSAssert(_flags.free == 1 && _zone != 0, NSInternalInconsistencyException);
options: (unsigned)mask
range: (NSRange)aRange
{
GS_RANGE_CHECK(aRange, ((GSStr)_parent)->_count);
if (aString == nil)
[NSException raise: NSInvalidArgumentException
format: @"[%@ -%@] nil string argument",
NSStringFromClass([self class]), NSStringFromSelector(_cmd)];
if (GSObjCIsInstance(aString) == NO)
[NSException raise: NSInvalidArgumentException
format: @"[%@ -%@] not a string argument",
NSStringFromClass([self class]), NSStringFromSelector(_cmd)];
if (((GSStr)_parent)->_flags.wide == 1)
return rangeOfString_u((GSStr)_parent, aString, mask, aRange);
else

View file

@ -381,10 +381,13 @@ GSEQ_STRCOMP(NSString *ss, NSString *os, unsigned mask, NSRange aRange)
unsigned oLength; /* Length of other. */
unsigned sLength = GSEQ_SLEN;
#if 0
/* Range should be checked in calling code */
if (aRange.location > sLength)
[NSException raise: NSRangeException format: @"Invalid location."];
if (aRange.length > (sLength - aRange.location))
[NSException raise: NSRangeException format: @"Invalid location+length."];
#endif
oLength = GSEQ_OLEN;
if (aRange.length == 0)
@ -604,11 +607,14 @@ GSEQ_STRRANGE(NSString *ss, NSString *os, unsigned mask, NSRange aRange)
/* Check that the search range is reasonable */
myLength = GSEQ_SLEN;
#if 0
/* Range should be checked in calling code */
if (aRange.location > myLength)
[NSException raise: NSRangeException format: @"Invalid location."];
if (aRange.length > (myLength - aRange.location))
[NSException raise: NSRangeException format: @"Invalid location+length."];
#endif
/* Ensure the string can be found */
strLength = GSEQ_OLEN;

View file

@ -1809,6 +1809,7 @@ handle_printf_atsign (FILE *stream,
options: (unsigned int)mask
range: (NSRange)aRange
{
GS_RANGE_CHECK(aRange, [self length]);
if (aString == nil)
[NSException raise: NSInvalidArgumentException format: @"range of nil"];
return strRangeNsNs(self, aString, mask, aRange);