Improve performance by handing out proxy to internal string

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@12418 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-Macdonald 2002-02-06 13:55:49 +00:00
parent e931b93591
commit d20683b862
3 changed files with 11 additions and 1 deletions

View file

@ -3,6 +3,10 @@
* Source/NSWindow.m: ([-sendEvent:]) handle mouse down in window if
no view accepts it. ([-mouseDown:]) implement to quietly ignore
event.
* Source/GSTextStorage.h: additional ivar
* Source/GSTextStorage.m: hand out a proxy to our internal storage,
to avoid either copying it (inefficient) or exposing the mutable
string (unsafe).
Wed Feb 6 02:30:09 2002 Nicola Pero <n.pero@mi.flashnet.it>

View file

@ -34,6 +34,7 @@
{
NSMutableString *_textChars;
NSMutableArray *_infoArray;
NSString *_textProxy;
}
@end

View file

@ -504,7 +504,11 @@ _attributesAtIndexEffectiveRange(
- (NSString*) string
{
return AUTORELEASE([_textChars copyWithZone: NSDefaultMallocZone()]);
if (_textProxy == nil)
{
_textProxy = RETAIN([_textChars immutableProxy]);
}
return _textProxy;
}
- (NSDictionary*) attributesAtIndex: (unsigned)index
@ -777,6 +781,7 @@ changeInLength: [aString length] - range.length];
- (void) dealloc
{
TEST_RELEASE(_textProxy);
RELEASE(_textChars);
RELEASE(_infoArray);
[super dealloc];