The Trunk: Collections-ul.681.mcz

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

The Trunk: Collections-ul.681.mcz

commits-2
Levente Uzonyi uploaded a new version of Collections to project The Trunk:
http://source.squeak.org/trunk/Collections-ul.681.mcz

==================== Summary ====================

Name: Collections-ul.681
Author: ul
Time: 19 March 2016, 1:39:02.54665 pm
UUID: 738dd2f1-c003-4e50-899b-371486e5c419
Ancestors: Collections-ul.680

- Let WriteStream's #nextPutAll: and #next:putAll:startingAt: take the quick route too when collection and aCollection are both strings of the same field size.
- PositionableStream >> #next:putAll:startingAt: can rely on the indexability of its argument, thus avoid creating copies of it. It also returns the collection argument, like other implementors of this method, instead of some copied subcollection.

=============== Diff against Collections-ul.680 ===============

Item was changed:
  ----- Method: PositionableStream>>next:putAll:startingAt: (in category 'accessing') -----
  next: anInteger putAll: aCollection startingAt: startIndex
  "Store the next anInteger elements from the given collection."
+
+ startIndex to: startIndex + anInteger - 1 do: [ :index |
+ self nextPut: (aCollection at: index) ].
+ ^aCollection!
- (startIndex = 1 and:[anInteger = aCollection size])
- ifTrue:[^self nextPutAll: aCollection].
- ^self nextPutAll: (aCollection copyFrom: startIndex to: startIndex+anInteger-1)!

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 |
+ (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 ].
- collection class == aCollection class ifFalse:
- [^ super next: anInteger putAll: aCollection startingAt: startIndex].
 
  newEnd := position + anInteger.
  newEnd > writeLimit ifTrue:
  [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 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 nextPutAll: aCollection ].
- collection class == aCollection class ifFalse:
- [^ super nextPutAll: aCollection ].
 
  newEnd := position + aCollection size.
  newEnd > writeLimit ifTrue:
  [self growTo: newEnd + 10].
 
  collection replaceFrom: position+1 to: newEnd  with: aCollection startingAt: 1.
  position := newEnd.
  ^aCollection!