mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-30 08:21:25 +00:00
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:
parent
6e285b1bba
commit
2c6d007051
3 changed files with 54 additions and 11 deletions
|
@ -2536,11 +2536,6 @@ rangeOfString_c(GSStr self, NSString *aString, unsigned mask, NSRange aRange)
|
||||||
{
|
{
|
||||||
Class c;
|
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);
|
c = GSObjCClass(aString);
|
||||||
if (GSObjCIsKindOf(c, GSUnicodeStringClass) == YES
|
if (GSObjCIsKindOf(c, GSUnicodeStringClass) == YES
|
||||||
|| (c == GSMutableStringClass && ((GSStr)aString)->_flags.wide == 1))
|
|| (c == GSMutableStringClass && ((GSStr)aString)->_flags.wide == 1))
|
||||||
|
@ -2558,11 +2553,6 @@ rangeOfString_u(GSStr self, NSString *aString, unsigned mask, NSRange aRange)
|
||||||
{
|
{
|
||||||
Class c;
|
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);
|
c = GSObjCClass(aString);
|
||||||
if (GSObjCIsKindOf(c, GSUnicodeStringClass) == YES
|
if (GSObjCIsKindOf(c, GSUnicodeStringClass) == YES
|
||||||
|| (c == GSMutableStringClass && ((GSStr)aString)->_flags.wide == 1))
|
|| (c == GSMutableStringClass && ((GSStr)aString)->_flags.wide == 1))
|
||||||
|
@ -3016,6 +3006,15 @@ transmute(GSStr self, NSString *aString)
|
||||||
options: (unsigned)mask
|
options: (unsigned)mask
|
||||||
range: (NSRange)aRange
|
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);
|
return rangeOfString_c((GSStr)self, aString, mask, aRange);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3329,6 +3328,15 @@ agree, create a new GSCInlineString otherwise.
|
||||||
options: (unsigned)mask
|
options: (unsigned)mask
|
||||||
range: (NSRange)aRange
|
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);
|
return rangeOfString_u((GSStr)self, aString, mask, aRange);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4127,6 +4135,15 @@ NSAssert(_flags.free == 1 && _zone != 0, NSInternalInconsistencyException);
|
||||||
options: (unsigned)mask
|
options: (unsigned)mask
|
||||||
range: (NSRange)aRange
|
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)
|
if (_flags.wide == 1)
|
||||||
return rangeOfString_u((GSStr)self, aString, mask, aRange);
|
return rangeOfString_u((GSStr)self, aString, mask, aRange);
|
||||||
else
|
else
|
||||||
|
@ -4590,6 +4607,7 @@ NSAssert(_flags.free == 1 && _zone != 0, NSInternalInconsistencyException);
|
||||||
options: (unsigned)mask
|
options: (unsigned)mask
|
||||||
range: (NSRange)aRange
|
range: (NSRange)aRange
|
||||||
{
|
{
|
||||||
|
GS_RANGE_CHECK(aRange, ((GSStr)_parent)->_count);
|
||||||
return [_parent rangeOfCharacterFromSet: aSet options: mask range: aRange];
|
return [_parent rangeOfCharacterFromSet: aSet options: mask range: aRange];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4597,6 +4615,15 @@ NSAssert(_flags.free == 1 && _zone != 0, NSInternalInconsistencyException);
|
||||||
options: (unsigned)mask
|
options: (unsigned)mask
|
||||||
range: (NSRange)aRange
|
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];
|
return [_parent rangeOfString: aString options: mask range: aRange];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4788,6 +4815,15 @@ NSAssert(_flags.free == 1 && _zone != 0, NSInternalInconsistencyException);
|
||||||
options: (unsigned)mask
|
options: (unsigned)mask
|
||||||
range: (NSRange)aRange
|
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)
|
if (((GSStr)_parent)->_flags.wide == 1)
|
||||||
return rangeOfString_u((GSStr)_parent, aString, mask, aRange);
|
return rangeOfString_u((GSStr)_parent, aString, mask, aRange);
|
||||||
else
|
else
|
||||||
|
|
|
@ -381,10 +381,13 @@ GSEQ_STRCOMP(NSString *ss, NSString *os, unsigned mask, NSRange aRange)
|
||||||
unsigned oLength; /* Length of other. */
|
unsigned oLength; /* Length of other. */
|
||||||
unsigned sLength = GSEQ_SLEN;
|
unsigned sLength = GSEQ_SLEN;
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
/* Range should be checked in calling code */
|
||||||
if (aRange.location > sLength)
|
if (aRange.location > sLength)
|
||||||
[NSException raise: NSRangeException format: @"Invalid location."];
|
[NSException raise: NSRangeException format: @"Invalid location."];
|
||||||
if (aRange.length > (sLength - aRange.location))
|
if (aRange.length > (sLength - aRange.location))
|
||||||
[NSException raise: NSRangeException format: @"Invalid location+length."];
|
[NSException raise: NSRangeException format: @"Invalid location+length."];
|
||||||
|
#endif
|
||||||
|
|
||||||
oLength = GSEQ_OLEN;
|
oLength = GSEQ_OLEN;
|
||||||
if (aRange.length == 0)
|
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 */
|
/* Check that the search range is reasonable */
|
||||||
myLength = GSEQ_SLEN;
|
myLength = GSEQ_SLEN;
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
/* Range should be checked in calling code */
|
||||||
if (aRange.location > myLength)
|
if (aRange.location > myLength)
|
||||||
[NSException raise: NSRangeException format: @"Invalid location."];
|
[NSException raise: NSRangeException format: @"Invalid location."];
|
||||||
if (aRange.length > (myLength - aRange.location))
|
if (aRange.length > (myLength - aRange.location))
|
||||||
[NSException raise: NSRangeException format: @"Invalid location+length."];
|
[NSException raise: NSRangeException format: @"Invalid location+length."];
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Ensure the string can be found */
|
/* Ensure the string can be found */
|
||||||
strLength = GSEQ_OLEN;
|
strLength = GSEQ_OLEN;
|
||||||
|
|
|
@ -1809,6 +1809,7 @@ handle_printf_atsign (FILE *stream,
|
||||||
options: (unsigned int)mask
|
options: (unsigned int)mask
|
||||||
range: (NSRange)aRange
|
range: (NSRange)aRange
|
||||||
{
|
{
|
||||||
|
GS_RANGE_CHECK(aRange, [self length]);
|
||||||
if (aString == nil)
|
if (aString == nil)
|
||||||
[NSException raise: NSInvalidArgumentException format: @"range of nil"];
|
[NSException raise: NSInvalidArgumentException format: @"range of nil"];
|
||||||
return strRangeNsNs(self, aString, mask, aRange);
|
return strRangeNsNs(self, aString, mask, aRange);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue