tiny optimisation to allow intermeidate substrings to be released earlier

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@35939 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
rfm 2013-01-08 08:25:18 +00:00
parent 4f4ab32e92
commit 6d9d73c0b4
2 changed files with 51 additions and 0 deletions

View file

@ -3846,6 +3846,33 @@ agree, create a new GSCInlineString otherwise.
DESTROY(_parent);
[super dealloc];
}
- (NSString*) substringFromRange: (NSRange)aRange
{
id s;
GS_RANGE_CHECK(aRange, _count);
s = createTinyString((char*)_contents.c + aRange.location, aRange.length);
if (nil == s)
{
s = substring_c((GSStr)_parent, aRange);
}
return s;
}
- (NSString*) substringWithRange: (NSRange)aRange
{
id s;
GS_RANGE_CHECK(aRange, _count);
s = createTinyString((char*)_contents.c + aRange.location, aRange.length);
if (nil == s)
{
s = substring_c((GSStr)_parent, aRange);
}
return s;
}
@end
@ -4220,6 +4247,21 @@ agree, create a new GSUInlineString otherwise.
DESTROY(_parent);
[super dealloc];
}
- (NSString*) substringFromRange: (NSRange)aRange
{
GS_RANGE_CHECK(aRange, _count);
aRange.location += (_contents.u - _parent->_contents.u);
return substring_u((GSStr)_parent, aRange);
}
- (NSString*) substringWithRange: (NSRange)aRange
{
GS_RANGE_CHECK(aRange, _count);
aRange.location += (_contents.u - _parent->_contents.u);
return substring_u((GSStr)_parent, aRange);
}
@end