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:
Richard Frith-MacDonald 2013-01-08 08:25:18 +00:00
parent fb2b132662
commit 9adb6e80dd
2 changed files with 51 additions and 0 deletions

View file

@ -1,3 +1,12 @@
2013-01-08 Richard Frith-Macdonald <rfm@gnu.org>
* Source/GSString.m:
When creating a substring (A) of a substring (B) or a string (C),
we now retain the (C) in (A) rather than having (C) retain (B)
which in turn retains (A). This has the advantage that it is
possible for the intermediate (B) to be released if nothing else
ues it.
2013-01-05 00:49-EST Gregory John Casamento <greg.casamento@gmail.com>
* Headers/Foundation/NSMetadata.h: Add _ to delegate.

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