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

Andreas Raab Andreas.Raab at gmx.de
Wed Oct 17 02:12:56 UTC 2001


Bijan,

The attached CS speeds RunArray>>, and #copyReplaceFrom:to:with: up by a
factor of roughly four. All it does is making both runs and values arrays
(there was some inconsistency between when to use OrderedCollections and
when not) plus a few minor modifications here and there. The overall result
for Text>>addAttribute:from:to: seems to be in the range of a factor of two
(although this may depend since #addAttribute: does some stuff besides).

Hope this helps,
  - Andreas

> -----Original Message-----
> From: squeak-dev-admin at lists.squeakfoundation.org
> [mailto:squeak-dev-admin at lists.squeakfoundation.org]On Behalf Of Bijan
> Parsia
> Sent: Tuesday, October 16, 2001 5:47 PM
> To: squeak-dev at lists.squeakfoundation.org
> Subject: [Q] RunArray>>, and #copyReplaceFrom:to:with:
>
>
> 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.
>
>
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: RunArrayTweaks-ar.2.cs
Type: application/octet-stream
Size: 5245 bytes
Desc: not available
Url : http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20011016/661f24f5/RunArrayTweaks-ar.2.obj


More information about the Squeak-dev mailing list