The Trunk: Collections-ul.392.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.392.mcz

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

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

Name: Collections-ul.392
Author: ul
Time: 18 October 2010, 4:55:37.186 am
UUID: 470b7171-1481-5340-83fc-56706d276e33
Ancestors: Collections-ul.391

- sped up SharedQueue by implementing SharedQueue >> #makeRoomAtEnd properly. The array holding the objects is grown/shrunk when needed.

=============== Diff against Collections-ul.391 ===============

Item was changed:
  ----- Method: SharedQueue>>makeRoomAtEnd (in category 'private') -----
  makeRoomAtEnd
+
  | contentsSize |
+ contentsSize := writePosition - readPosition.
+ contentsSize * 2 > contentsArray size
+ ifTrue: [
+ "grow"
+ contentsArray := (contentsArray class new: contentsArray size * 2)
- readPosition = 1
- ifTrue: [contentsArray := contentsArray , (Array new: 10)]
- ifFalse:
- [contentsSize := writePosition - readPosition.
- "BLT direction ok for this. Lots faster!!!!!!!!!!!! SqR!!!! 4/10/2000 10:47"
- contentsArray
  replaceFrom: 1
  to: contentsSize
  with: contentsArray
+ startingAt: readPosition;
+ yourself ]
+ ifFalse: [
+ (contentsArray size > 10 and: [ contentsSize * 4 <= contentsArray size ])
+ ifTrue: [
+ "shrink"
+ contentsArray := (contentsArray class new: (contentsSize * 2 max: 10))
+ replaceFrom: 1
+ to: contentsSize
+ with: contentsArray
+ startingAt: readPosition;
+ yourself ]
+ ifFalse: [
+ "just move the elements to the front"
+ contentsArray
+ replaceFrom: 1
+ to: contentsSize
+ with: contentsArray
+ startingAt: readPosition.
+ contentsArray
+ from: contentsSize + 1
+ to: contentsArray size
+ put: nil ] ].
+ readPosition := 1.
+ writePosition := contentsSize + 1!
- startingAt: readPosition.
- "nil out remainder --bf 10/25/2005"
- contentsArray
- from: contentsSize+1
- to: contentsArray size
- put: nil.
- readPosition := 1.
- writePosition := contentsSize + 1]!