Yes it makes big differences when you mix ByteString/ByteArray for example... Or shouldn't we just let #replaceFrom:to:with:startingAt: do the job ? That's what I did in my own image in #next:putAll:startingAt:, I completely removed the test and it seems to work well. I then let #nextPutAll: invoke this one. I'm not completely sure that #replaceFrom:to:with:startingAt: will do the right thing with every pair of Collection class, but we are streaming on a restricted sub-hierarchy in practice. We should eventually test it. Nicolas 2012/1/8 Mariano Martinez Peck <marianopeck@gmail.com>:
Hi guys. Some time ago Henry spot to us a small improvement for WriteStream
nextPutAll: that we are using in Fuel, but I think it can be general. Henry comment was exactly:
Also: For variableBytes classes, if you rewrite:
WriteStream nextPutAll: aCollection
    | newEnd |     collection class instSpec == aCollection class instSpec ifFalse:        [^ super nextPutAll: aCollection ].
    newEnd := position + aCollection size.     newEnd > writeLimit ifTrue:        [self growTo: newEnd + 10].
    collection replaceFrom: position+1 to: newEnd with: aCollection startingAt: 1.     position := newEnd.
   ^ aCollection
You can now pass all variableByte classes (Like ByteString) directly to a stream with a ByteArray collection, and the replaceFrom:to:with: startingAt: primitive will work correctly, just like the file primitive does This means you don't need special Serializers for these either, using f.ex. clunky nextStringPutAll: methods with manual asByteArray conversions.
So...if you agree, I can commit the patch.
Let me know.
-- Mariano http://marianopeck.wordpress.com