File tree Expand file tree Collapse file tree 2 files changed +18
-4
lines changed
Expand file tree Collapse file tree 2 files changed +18
-4
lines changed Original file line number Diff line number Diff line change @@ -178,12 +178,19 @@ AbstractBinaryFileStream >> next: n into: aString startingAt: startIndex [
178178
179179{ #category : ' writing' }
180180AbstractBinaryFileStream >> next: amount putAll: aByteArray [
181+
182+ ^ self next: amount putAll: aByteArray startingAt: 1
183+ ]
184+
185+ { #category : ' accessing' }
186+ AbstractBinaryFileStream >> next: amount putAll: aByteArray startingAt: startingIndex [
187+
181188 forWrite
182189 ifFalse: [ ^ self error: ' Cannot write a read-only file' ].
183190 [ File
184191 write: handle
185192 from: aByteArray
186- startingAt: 1
193+ startingAt: startingIndex
187194 count: amount ]
188195 on: PrimitiveFailed
189196 do: [ (FileWriteError fileName: self name)
Original file line number Diff line number Diff line change @@ -38,18 +38,25 @@ ChunkWriteStream >> duplicateTerminatorMarkOn: aString [
3838
3939 | string start bangIndex newStringStream |
4040 string := aString asString.
41- newStringStream := WriteStream on: (string species new : string size * 2 ).
4241 start := 1 .
42+ bangIndex := string indexOf: self terminatorMark startingAt: start.
43+
44+ " We check the bang ahead, so we can avoid two allocations of the string!"
45+ (bangIndex = 0 )
46+ ifTrue: [ ^ string copyWith: self terminatorMark ].
47+
48+ newStringStream := WriteStream on: (string species new : string size * 2 ).
4349
44- [ ( bangIndex := string indexOf: self terminatorMark startingAt: start) = 0 ]
50+ [ bangIndex = 0 ]
4551 whileFalse: [
4652 newStringStream
4753 next: bangIndex - start + 1
4854 putAll: string
4955 startingAt: start.
5056
5157 newStringStream nextPut: self terminatorMark. " double it"
52- start := bangIndex + 1 ].
58+ start := bangIndex + 1 .
59+ bangIndex := string indexOf: self terminatorMark startingAt: start ].
5360
5461 newStringStream
5562 next: string size - start + 1
You can’t perform that action at this time.
0 commit comments