From 6482c6835a6971c32b6feaf54a8983bee3faf16b Mon Sep 17 00:00:00 2001 From: Andrew McCallum Date: Sat, 7 Sep 1996 17:47:24 +0000 Subject: [PATCH] ([NSGCString -substringFromRange:]): New method, overrides superclass method with more efficient implementation. (From Eric Norum.) git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@1706 72102866-910b-0410-8b05-ffd578937521 --- Source/NSGCString.m | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Source/NSGCString.m b/Source/NSGCString.m index f3d98bc30..7f3bef8b0 100644 --- a/Source/NSGCString.m +++ b/Source/NSGCString.m @@ -128,6 +128,20 @@ return (unichar) _contents_chars[index]; } +- (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; +} + // FOR IndexedCollection SUPPORT; - objectAtIndex: (unsigned)index