mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-26 10:11:03 +00:00
([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:
parent
6482c6835a
commit
64a08d0771
1 changed files with 2 additions and 6 deletions
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue