Word processing in Squeak?

Tim Rowledge tim at sumeru.stanford.edu
Wed Feb 16 19:45:55 UTC 2000


> > - No support for long documents.  A workspace for example becomes
> dead-slow
> > if you want to edit 1MB or more.  Winword is still very fast.  Even my
> > little faithful NotGNU editor can handle this without problems.
> 
> I think some of the algorithms used need fixing.
Marcel is right - it's simply a matter of fixing some of the algorithms.
ParagraphEditor is designed to cope with simple, small texts. To handle
big documents you need to keep your text in a more efficient manner than
jsut a big String; imagine how much work it is to add a character in the
middle of a 1Mb String!
Make a copy of the first half
Make a copy of the second half.
concatenate a String made from the new char to the first half - creating
another new String in the process
concatenate the second half to this string.
So in the naive case, you start with a 1Mb string, create 2 0.5Mb 
Strings, a 0.5mb+1byte String and a 1Mb+1byte string and then have to GC
the dead ones. 
A smarter version creates the 1Mb+1byte string and copies 0.5Mb, 1 byte
and 0.5Mb, which STILL takes a while.

To do better you need to do things like the GapString in VW, or keep
your documents as lists of paragraphs, or something more structured.

A Simple Matter Of Programming :-)

tim







More information about the Squeak-dev mailing list