[Pkg] The Trunk: Collections-nice.576.mcz

commits at source.squeak.org commits at source.squeak.org
Thu Jul 24 20:36:56 UTC 2014


Nicolas Cellier uploaded a new version of Collections to project The Trunk:
http://source.squeak.org/trunk/Collections-nice.576.mcz

==================== Summary ====================

Name: Collections-nice.576
Author: nice
Time: 24 July 2014, 10:36:08.474 pm
UUID: 1ec2cb3f-f168-4b7b-9ec1-57ae79508f5d
Ancestors: Collections-eem.575

Convert a WriteStream into a ReadStream.
Beware, this version is optimized to avoid a copy, but is sharing some state.
Thus:

	s := WriteStream on: String new.
	self writeSomethingOn: s.
	self readSomethingFrom: s readStream.

is a good replacement for:

	s := ReadWriteStream on: String new.
	self writeSomethingOn: s.
	self readSomethingFrom: s reset

But avoid overwriting like this:

	w := String new writeStream.
	self writeSomethingOn: w.
	r := w readStream.
	self writeSomethingElseOn: w reset.
	self compare: r to: w readStream.

=============== Diff against Collections-eem.575 ===============

Item was added:
+ ----- Method: WriteStream>>readStream (in category 'converting') -----
+ readStream
+ 	"Answer a readStream on my contents truncated to current position.
+ 	Beware, the readStream shares the contents, so it will be modified if I'm written backward."
+ 	readLimit := readLimit max: position.
+ 	^ReadStream on: collection from: (initialPositionOrNil ifNil: [1]) to: position!



More information about the Packages mailing list