NeoCSV
NeoCSV copied to clipboard
use stream's nextPutAll:
what do you think?
it works because reader implements do:
That is very clever ;-)
Now, it depends on a particular implementation of #nextPutAll: (the one in Stream). Looking at all implementations, I see some which would probably fail.
On the other hand, in this case we only need what #streamContents: uses.
The question remains if this change would improve the clarity of this already simple code, or obscure it.
good question.
i debug the following example
(NeoCSVReader on: '"1",,"3"' readStream) upToEnd
and it depends on
WriteStream>>nextPutAll: and given the first stmt
collection class == aCollection class ifFalse: [^ super nextPutAll: aCollection ].
it goes to
Stream>>#nextPutAll: aCollection
"Append the elements of aCollection to the sequence of objects accessible
by the receiver. Answer aCollection."
aCollection do: [:v | self nextPut: v].
^aCollection
and then goes to WriteStream>>#nextPut:.
the message send is longer with more dependencies.
the previous version had one dependency WriteStream>>#nextPut:
in any case it always depends on WriteStream(Collections-Streams).
just showing off a clever hack.