Levente Uzonyi uploaded a new version of Collections to project The Trunk: http://source.squeak.org/trunk/Collections-ul.932.mcz
==================== Summary ====================
Name: Collections-ul.932 Author: ul Time: 31 March 2021, 2:12:26.200489 am UUID: a61726a6-a12e-4074-a25f-8220699d3c06 Ancestors: Collections-dtl.931
- use #grownBy: in WriteStream >> #growTo: to grow the collection because that works for OrderedCollections too. - do not add 10 to the argument passed to WriteStream >> #growTo:. It will already increase its argument by at least 20.
=============== Diff against Collections-dtl.931 ===============
Item was changed: ----- Method: LimitedWriteStream>>nextPutAll: (in category 'writing') ----- nextPutAll: aCollection
| newEnd | collection class == aCollection class ifFalse: [^ super nextPutAll: aCollection ].
newEnd := position + aCollection size. newEnd > limit ifTrue: [ super nextPutAll: (aCollection copyFrom: 1 to: (limit - position max: 0)). limitBlock value. ^aCollection ]. newEnd > writeLimit ifTrue: [ + self growTo: newEnd - self growTo: newEnd + 10 ].
collection replaceFrom: position+1 to: newEnd with: aCollection startingAt: 1. position := newEnd. ^aCollection!
Item was changed: ----- Method: TextStream>>nextPutAll: (in category 'writing') ----- nextPutAll: aCollection "Optimized access to get around Text at:Put: overhead" | n | n := aCollection size. position + n > writeLimit ifTrue: + [self growTo: position + n]. - [self growTo: position + n + 10]. collection replaceFrom: position+1 to: position + n with: aCollection startingAt: 1. position := position + n. ^aCollection!
Item was changed: ----- Method: WriteStream>><< (in category 'printing') ----- << aCollection "we want a readable version of nextPutAll however it may be difficult to fully recreate nextPutAll: for all the different types of stream. Rather then simply send to nextPutAll: we handle the String (or ByteArray) argument as fast as possible - the rest we delegate to putOn: This means that we handle single characters and bytes whereas nextPutAll: is only for sequencable collections. . Note this may not work in every case that nextPutAll: does subject to extensive testing, but it should work in the important cases"
| newEnd | collection class == aCollection class ifFalse: [ aCollection putOn: self. ^ self ].
newEnd := position + aCollection size. newEnd > writeLimit ifTrue: + [self growTo: newEnd]. - [self growTo: newEnd + 10].
collection replaceFrom: position+1 to: newEnd with: aCollection startingAt: 1. position := newEnd.
!
Item was changed: ----- Method: WriteStream>>growTo: (in category 'private') ----- growTo: anInteger + " anInteger is the required minimal new size of the collection "
+ | oldSize newSize | - " anInteger is the required minimal new size of the collection " - | oldSize grownCollection newSize | oldSize := collection size. + newSize := anInteger + (oldSize // 4 max: 20). + collection := collection grownBy: newSize - oldSize. - newSize := anInteger + (oldSize // 4 max: 20). - grownCollection := collection class new: newSize. - collection := grownCollection replaceFrom: 1 to: oldSize with: collection startingAt: 1. writeLimit := collection size. !
Item was changed: ----- Method: WriteStream>>next:putAll:startingAt: (in category 'accessing') ----- next: anInteger putAll: aCollection startingAt: startIndex "Store the next anInteger elements from the given collection."
| newEnd | anInteger > 0 ifFalse: [ ^aCollection ]. (collection class == aCollection class or: [ collection isString and: [ aCollection isString and: [ collection class format = aCollection class format ] ] ]) "Let Strings with the same field size as collection take the quick route too." ifFalse: [ ^super next: anInteger putAll: aCollection startingAt: startIndex ].
newEnd := position + anInteger. newEnd > writeLimit ifTrue: + [self growTo: newEnd]. - [self growTo: newEnd + 10].
collection replaceFrom: position+1 to: newEnd with: aCollection startingAt: startIndex. position := newEnd.
^aCollection!
Item was changed: ----- Method: WriteStream>>nextPutAll: (in category 'accessing') ----- nextPutAll: aCollection
| newEnd | (collection class == aCollection class or: [ collection class isBits and: [ aCollection isString and: [ collection class format = aCollection class format ] ] ]) "Let Strings with the same field size as collection take the quick route too." ifFalse: [ ^ super nextPutAll: aCollection ].
newEnd := position + aCollection size. newEnd > writeLimit ifTrue: + [self growTo: newEnd]. - [self growTo: newEnd + 10].
collection replaceFrom: position+1 to: newEnd with: aCollection startingAt: 1. position := newEnd. ^aCollection!