In-memory stream performance on word data
Joshua 'Schwa' Gargus
schwa at cc.gatech.edu
Sat Aug 23 16:39:40 UTC 2003
On Sat, Aug 23, 2003 at 12:28:16AM -0700, Yoshiki Ohshima wrote:
> Josh,
>
> I don't fully understand the problem you describe, since I don't
> find an image with RWBinaryOrTextStream>>nextPutAll:.
I acidentally saved my image a couple of days ago with Andreas'
ZippierStreams changeset loaded in... I knew it would cause me problems!
> Are you looking
> for something that does the opposite operation of
> PositionableStream>>nextWordsInto:?
Yes.
>
> One way to do this would be:
>
> words _ B3DRotationArray new: 2.
> words at: 1 put: (B3DRotation radiansAngle: 1.57 axis: (B3DVector3 x: 1.0 y: 2.0 z: 3.0)). "or whatever."
>
> bytes _ ByteArray new: words basicSize * 4. "basicSize returns the size in 4 bytes unit."
> hack _ Form new hackBits: bytes.
> eightForm _ Form extent: 4@(bytes size // 4) depth: 8 bits: words.
> Smalltalk isLittleEndian ifTrue:[hack swapEndianness].
> eightForm displayOn: hack.
> "bytes holds the serialized data."
Where in the Stream hierarchy should I put something like the above?
RWBinaryOrTextStream>>nextWordsPutAll:?
Thanks,
Joshua
(now to read Boris' email... it looks like he had a lot to say on the topic)
>
> Then, a la Bitmap>>copyFromByteArray:,
>
> newWords _ B3DRotationArray new: 2.
> myHack := Form new hackBits: newWords.
> byteHack := Form new hackBits: bytes.
> Smalltalk isLittleEndian ifTrue:[byteHack swapEndianness].
> byteHack displayOn: myHack.
>
> newWords = words.
> "=> true"
>
> I'm not sure this makes it faster (probably does), but may be worth
> to try.
>
> The hackBits thing is picky about the four byte boundary, so I kind
> of imagine that do this directly into a byte array of the 'collection'
> of a Stream.
>
> -- Yoshiki
More information about the Squeak-dev
mailing list
|