From 64a08d0771ec2dcf0644b279257e7ecce7af8a0c Mon Sep 17 00:00:00 2001 From: Andrew McCallum Date: Sat, 7 Sep 1996 17:54:08 +0000 Subject: [PATCH] ([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 --- Source/NSGCString.m | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/Source/NSGCString.m b/Source/NSGCString.m index 7f3bef8b0..aea213351 100644 --- a/Source/NSGCString.m +++ b/Source/NSGCString.m @@ -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;