• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
NSTextView/Storage Fast deletion?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: NSTextView/Storage Fast deletion?
      • From: Max Horn <email@hidden>
  • Prev by Date: Converting NSAppleEventDescriptor to AppleEvent
  • Next by Date: Re: Standard OS X Compression format
  • Previous by thread: Re: Converting NSAppleEventDescriptor to AppleEvent
  • Next by thread: Re: NSTextView/Storage Fast deletion?
  • Index(es):
    • Date
    • Thread