([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
This commit is contained in:
mccallum 1996-09-07 17:47:24 +00:00
parent 7f7b75786e
commit d8fb0d2318

View file

@ -128,6 +128,20 @@
return (unichar) _contents_chars[index]; 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; // FOR IndexedCollection SUPPORT;
- objectAtIndex: (unsigned)index - objectAtIndex: (unsigned)index