Mariano,
On 18 May 2011, at 14:29, Mariano Martinez Peck wrote:
> Sven, I improved quite a lot using your buffered write stream.
> What I don't understans is why MultiByteFileStream doesn't perform as good
> as them.
> If I see StandardFileStream has an internal buffer called 'buffer1'.
>
> So why is that much difference between using MultiByteFileStream directly and
> a WriteStream (ByteArray new writeSteam ) or ZnBufferedWriteStream ?
I just looked briefly at the hierarchy, it seems that buffer1 is an output
buffer of size 1 !
Have a look at
StandardFileStream>>#nextPut: char
"Write the given character to this file."
rwmode ifFalse: [^ self error: 'Cannot write a read-only file'].
collection ifNotNil: [
position < readLimit ifTrue: [ self flushReadBuffer ] ].
buffer1 at: 1 put: char.
self primWrite: fileID from: buffer1 startingAt: 1 count: 1.
^ char
There is simply no buffering going on.
buffer1 is a mystery to me ;-)
Sven
BTW: the above method flushes the READ buffer while WRITING,
there is probably an explanation for this, but I can't think of one.