|
From: | Alexander Malmberg |
Subject: | Re:Modest string handling optimisations (Was: [Gnustep-cvs] gnustep/core/base ChangeLog Source/NSString.m) |
Date: | Thu, 26 Aug 2004 02:01:41 +0200 |
User-agent: | Mozilla Thunderbird 0.5 (X11/20040306) |
Richard Frith-Macdonald wrote:
Log message: Modest string handling optimisations.
>...
RCS file: /cvsroot/gnustep/cvsroot/gnustep/gnustep/core/base/Source/NSString.m,v retrieving revision 1.324 retrieving revision 1.325 ... @@ -2541,21 +2543,32 @@ */ - (NSString*) lowercaseString
>...
+ if (start.length == 0) + { + return self; + }
This should be "return [[self copy] autorelease];". The current code gets the lifetime of the returned string wrong; consider:
{NSString *foo=[[NSString alloc] init...]; /* do some string manipulation */
NSString *returnValue=[foo lowercaseString]; [foo release]; return returnValue; }It also fails if the string is mutable. There are some other cases of this in NSString that I've been meaning to fix for a while.
- Alexander Malmberg
[Prev in Thread] | Current Thread | [Next in Thread] |