[Q] RunArray>>, and #copyReplaceFrom:to:with:

Bijan Parsia bparsia at email.unc.edu
Wed Oct 17 00:47:14 UTC 2001


I was dorking around with colorizing some HTML tags (for a SqueakNews
column) and I noticed that as my test document got longer, accepting it
took a *long* time. I *thought* this was because I parse the document on
accept (to extract the title). Boy was I *wrong*! Parsing was very
nippy. My other hunch was the use of
HTMLformatter>>rangesOfAngleBrackets:, again, not a problem. No, the
problem was the use of Text>>addAttribute:from:to:, specifically with
RunArray>>copyReplaceFrom:to:with:

  copyReplaceFrom: start to: stop with: replacement

	^(self copyFrom: 1 to: start - 1)
		, replacement 
		, (self copyFrom: stop + 1 to: self size)

Now, I know , can be slow, yadda yadda yadda, but I don't see a simple way
to use a stream here. I peeked at VisualWorks and it has a bunch of stuff
to optimize this sort of thing.

So my question is: How interesting is it to optimize this? Browsing
senders of #addAttribute:from:to: didn't reveal that much to me (is there
a good way to profile "general use" of a method as I engage in routine
activities)? I really like Texts but I'm beginning to worry that they
might not be all that nippy (e.g., if I have lots and lots of attributes
and emphasis, etc.).

Any thoughts, advice, speculations, etc. anyone cares to offer would be
most welcome.

Cheers,
Bijan Parsia.





More information about the Squeak-dev mailing list