NSTextView/Storage Fast deletion?
NSTextView/Storage Fast deletion?
- Subject: NSTextView/Storage Fast deletion?
- From: Brian Chapeau <email@hidden>
- Date: Sun, 18 Nov 2001 02:12:04 -0600
I'm pretty new to Cocoa, and am writing an enhanced telnet client (with
obj-c). I'm at a point where I have serious preformance issues, and am
wondering if anyone has any suggestions:
I've got a simple NSTextView which has text arriving from the telnet
connection, and am implementing a maximum scrollback history. However, the
way I'm doing it is extremely slow and causes a large delay if a large
amount of text is coming on the screen. What I'm doing is getting the
NSTextStorage item from the NSTextView, then replacing characters at the
beginning of that with an empty string. This operation seems to be my
problem (as when I remove it I get respectable update speed).
Basically it looks something like:
NSTextStorage *storage = [textView textStorage];
[storage beginEditing];
// I append new text here. This seems decently fast.
if ([storage length] > maxLength)
{
NSRange range;
range.location = 0;
range.length = [storage length] - maxLength;
[storage replaceCharactersInRange:range with:@""];
}
[storage endEditing];
(This is just from memory, so I hope the function names I've recalled are
the right ones.)
I've noted that the Terminal program does not have a problem when it reaches
its max scrollback.
Brian Chapeau
email@hidden