([NSGCString -substringFromRange:]): Don't always return a mutable

string class; return the same mutable/immutable string class as self.
This also simplies the code.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@1707 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Andrew McCallum 1996-09-07 17:54:08 +00:00
parent 6482c6835a
commit 64a08d0771

View file

@ -130,16 +130,12 @@
- (NSString*) substringFromRange: (NSRange)aRange
{
NSGMutableCString *s;
if (aRange.location > _count)
[NSException raise: NSRangeException format:@"Invalid location."];
if (aRange.length > (_count - aRange.location))
[NSException raise: NSRangeException format:@"Invalid location+length."];
s = [[NSGMutableCString alloc] initWithCapacity:aRange.length+1];
[s setCString:_contents_chars+aRange.location length:aRange.length];
[s autorelease];
return (NSString *)s;
return [[self class] stringWithCString: _contents_chars + aRange.location
length: aRange.length];
}
// FOR IndexedCollection SUPPORT;