[FIX] TextStreamFix ([er] questions)

Daniel Vainsencher danielv at netvision.net.il
Sun Jun 8 21:20:08 UTC 2003

Boris Gaertner <Boris.Gaertner at gmx.net> wrote:
> <danielv at netvision.net.il> wrote_
> > In using replaceFrom: position+1 to: position + n with: aCollection
> > startingAt: 1, I think you're fixing the wrong thing - you're working
> > around the real culprit, which is that Text>>replaceFrom:to:with: does
> > copying, which is quite contrary to other implementations of the same
> > selector.
> SequenceableCollection>>replaceFrom:to:with:
> delegates to the modifying method
> replaceFrom:to:with:startingAt:,
> and Text does not do that. There are no other
> implementors of replaceFrom:to:with: in the standard 3.4
> image.
> Text has also an in-place replacement method. It is
> replaceFrom: start to: stop with: replacement startingAt: repStart
I know. Since #replaceFrom:to:with: is supposed to be destructive, I'm
saying that instead of working around it, by using the lower level
#replaceFrom:to:with:startingAt: it might be better to fix
#replaceFrom:to:with: to be destructive, and then using it won't be
computationally expensive. The benefit is that you're preventing many
potential future performance bugs, instead of just this one you've

To make a long story short, seems to me like if Ted's code is correct,
then the following should work well and fast. 
replaceFrom: start to: stop with: aText

	^super replaceFrom: start to: stop with: aText asText

But I haven't looked at this very deeply. Am I missing something?

[everything else about Text operations]
Sorry, but I've run out of steam. All that ugly code is depressing me.
How would you feel about doing some groundwork on those classes and
their clients, and then writing some tests that check the
Text/TextStream API? this would be a good prelude to the kind of deep
cleanup these classes are begging for (IMHO).


More information about the Squeak-dev mailing list