<div dir="ltr"><div><div>It&#39;s messing too much with stream states to my taste, this lacks encapsulation...<br></div><div>Eventually, stream position = stream originalContents size would be a simpler test (no mutation required) if we must really have a translucent WriteStream.<br>
</div></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">2014/1/19  <span dir="ltr">&lt;<a href="mailto:commits@source.squeak.org" target="_blank">commits@source.squeak.org</a>&gt;</span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
David T. Lewis uploaded a new version of Collections to project The Inbox:<br>
<a href="http://source.squeak.org/inbox/Collections-dtl.562.mcz" target="_blank">http://source.squeak.org/inbox/Collections-dtl.562.mcz</a><br>
<br>
==================== Summary ====================<br>
<br>
Name: Collections-dtl.562<br>
Author: dtl<br>
Time: 19 January 2014, 2:06:03.032 pm<br>
UUID: 5ffdcb69-50fb-4dbd-8da0-db2193fe9a0a<br>
Ancestors: Collections-cwp.561<br>
<br>
A possible fix for WriteStreamTest&gt;&gt;testStreamContentsPositioning<br>
<br>
Change SequencebleCollection class&gt;&gt;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.<br>

<br>
=============== Diff against Collections-cwp.561 ===============<br>
<br>
Item was changed:<br>
  ----- Method: SequenceableCollection class&gt;&gt;new:streamContents: (in category &#39;stream creation&#39;) -----<br>
  new: newSize streamContents: blockWithArg<br>
<br>
+       | stream p endPos |<br>
-       | stream |<br>
        stream := WriteStream on: (self new: newSize).<br>
        blockWithArg value: stream.<br>
+       p := stream position.<br>
+       endPos := stream setToEnd position.<br>
+       p = endPos<br>
+               ifTrue: [p = newSize<br>
+                               ifTrue: [^ stream originalContents]]<br>
+               ifFalse: [stream position: p].<br>
+       ^ stream contents!<br>
-       stream position = newSize<br>
-               ifTrue: [ ^stream originalContents ]<br>
-               ifFalse: [ ^stream contents ]!<br>
<br>
<br>
</blockquote></div><br></div>