The Inbox: Collections-dtl.562.mcz

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

The Inbox: Collections-dtl.562.mcz

commits-2
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 ]!


Reply | Threaded
Open this post in threaded view
|

Re: The Inbox: Collections-dtl.562.mcz

Nicolas Cellier
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 <[hidden email]>
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 ]!