[squeak-dev] The Inbox: CollectionsTests-dtl.212.mcz

David T. Lewis lewis at mail.msen.com
Sun Jan 19 18:41:24 UTC 2014


On Sun, Jan 19, 2014 at 06:06:37PM +0100, Levente Uzonyi wrote:
> On Sun, 19 Jan 2014, Nicolas Cellier wrote:
> 
> >It's a bug. Let's remove the optimizatoin. If we really want it, this 
> >could be a implemented like
> >
> >WriteStream>>sharedContents? | sz | ^(sz := position max: readLimit) = 
> >collection size ifTrue: [collection] ifFalse: [collection copyFrom: 1 to:
> >sz]
> 
> #new:streamContents: is about optimization, nothing else. I think it's a 
> better solution to set the stream to the end before comparing the position 
> with the size, because I don't see any other possible use for
> #sharedContents.

Do you mean something like this?

  new: newSize streamContents: blockWithArg
      | stream p endPos |
      stream := WriteStream on: (self new: newSize).
      blockWithArg value: stream.
      p := stream position.
      endPos := stream setToEnd position.
      p = endPos
          ifTrue: [p = newSize
                  ifTrue: [^ stream originalContents]]
          ifFalse: [stream position: p].
      ^ stream contents


I'm not sure what that would do to the performance gains.

Dave



More information about the Squeak-dev mailing list