'From etoys5.0 of 29 March 2012 [latest update: #2406] on 11 March 2018 at 8:45:54 am'! "Change Set: BigBinaryReadFix Date: 11 March 2018 Author: Bob Arning In loading a large ImageSegment for a Project, lowSpace was reached. Reading the segment required 3 full copies, one in the ReadStream, one as the String just read and one for the ByteArray to convert the String into. Eliminate one of these by reading directly into a ByteArray if the ReadStream is in binary mode."! !ReadWriteStream methodsFor: 'accessing' stamp: 'raa 3/11/2018 08:34'! nextBinary: anInteger "Answer the next anInteger elements of my collection. overriden for efficiency" | ans endPosition | readLimit := readLimit max: position. endPosition _ position + anInteger min: readLimit. ans _ ByteArray new: endPosition - position. ans replaceFrom: 1 to: ans size with: collection startingAt: position+1 . position _ endPosition. ^ans ! ! !MultiByteBinaryOrTextStream methodsFor: 'public' stamp: 'raa 3/11/2018 08:34'! next: anInteger | multiString | "self halt." self isBinary ifTrue: [^ (super nextBinary: anInteger)]. multiString _ WideString new: anInteger. 1 to: anInteger do: [:index | | character | (character _ self next) ifNotNil: [ multiString at: index put: character ] ifNil: [ multiString _ multiString copyFrom: 1 to: index - 1. ^ multiString ] ]. ^ multiString. ! !