[squeak-dev] The Inbox: Collections-dtl.562.mcz

Nicolas Cellier nicolas.cellier.aka.nice at gmail.com
Sun Jan 19 20:32:16 UTC 2014


It's messing too much with stream states to my taste, this lacks
encapsulation...
Eventually, stream position = stream originalContents size would be a
simpler test (no mutation required) if we must really have a translucent
WriteStream.


2014/1/19 <commits at source.squeak.org>

> David T. Lewis uploaded a new version of Collections to project The Inbox:
> http://source.squeak.org/inbox/Collections-dtl.562.mcz
>
> ==================== Summary ====================
>
> Name: Collections-dtl.562
> Author: dtl
> Time: 19 January 2014, 2:06:03.032 pm
> UUID: 5ffdcb69-50fb-4dbd-8da0-db2193fe9a0a
> Ancestors: Collections-cwp.561
>
> A possible fix for WriteStreamTest>>testStreamContentsPositioning
>
> Change SequencebleCollection class>>new:streamContents: so that the
> optimization to answer originalContents is not invoked if the stream
> collection has been expanded. This permits the stream to be positioned
> forward then back to the position matching its original size.
>
> =============== Diff against Collections-cwp.561 ===============
>
> Item was changed:
>   ----- Method: SequenceableCollection class>>new:streamContents: (in
> category 'stream creation') -----
>   new: newSize streamContents: blockWithArg
>
> +       | stream p endPos |
> -       | stream |
>         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!
> -       stream position = newSize
> -               ifTrue: [ ^stream originalContents ]
> -               ifFalse: [ ^stream contents ]!
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20140119/ef9a43a3/attachment.htm


More information about the Squeak-dev mailing list