Skip to content

Commit

Permalink
[feenkcom/gtoolkit#3295] Fix bug in `BlRopeableCollectionFile>>copyFr…
Browse files Browse the repository at this point in the history
…om:to:` to fix failing example
  • Loading branch information
refactoringdr committed May 31, 2023
1 parent 663ccce commit 9ccb34a
Showing 1 changed file with 2 additions and 21 deletions.
23 changes: 2 additions & 21 deletions src/Bloc/BlRopeableCollectionFile.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -129,27 +129,8 @@ BlRopeableCollectionFile >> close [

{ #category : #copying }
BlRopeableCollectionFile >> copyFrom: startIndex to: endIndex [
| length results receiverIndex bufferIndex resultIndex |

self ensureBuffered: startIndex.
length := endIndex - startIndex + 1.
length <= 0 ifTrue: [ ^ '' ].
results := String new: length.
receiverIndex := startIndex.
resultIndex := 1.
bufferIndex := startIndex - bufferStart + 1.

[ receiverIndex <= endIndex ] whileTrue:
[ bufferIndex > bufferedSize ifTrue:
[ self ensureBuffered: receiverIndex.
bufferIndex := receiverIndex - bufferStart ].
results at: resultIndex put: (buffer at: bufferIndex).
receiverIndex := receiverIndex + 1.
resultIndex := resultIndex + 1.
bufferIndex := bufferIndex + 1. ].

^ results

^ String
streamContents: [ :str | startIndex to: endIndex do: [ :i | str nextPut: (self at: i) ] ]
]

{ #category : #copying }
Expand Down

0 comments on commit 9ccb34a

Please sign in to comment.