Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSTextView/Storage Fast deletion?



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




Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.