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

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

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

Name: Collections-ul.727
Author: ul
Time: 6 December 2016, 7:01:42.838977 pm
UUID: 08250fa9-de61-4316-a96e-c2e4d3e53d1a
Ancestors: Collections-topa.726

- micro-optimized OrderedCollection's #first, #last, #removeFirst and #removeLlast

=============== Diff against Collections-topa.726 ===============

Item was added:
+ ----- Method: OrderedCollection>>first (in category 'accessing') -----
+ first
+
+ firstIndex > lastIndex ifTrue: [ self errorNoSuchElement ].
+ ^array at: firstIndex!

Item was added:
+ ----- Method: OrderedCollection>>last (in category 'accessing') -----
+ last
+
+ firstIndex > lastIndex ifTrue: [ self errorNoSuchElement ].
+ ^array at: lastIndex!

Item was changed:
  ----- Method: OrderedCollection>>removeFirst (in category 'removing') -----
  removeFirst
  "Remove the first element of the receiver and answer it. If the receiver is
  empty, create an error notification."
+
  | firstObject |
+ firstIndex > lastIndex ifTrue: [ self errorEmptyCollection ].
- self emptyCheck.
  firstObject := array at: firstIndex.
  array at: firstIndex put: nil.
  firstIndex := firstIndex + 1.
+ ^firstObject!
- ^ firstObject!

Item was changed:
  ----- Method: OrderedCollection>>removeLast (in category 'removing') -----
  removeLast
  "Remove the last element of the receiver and answer it. If the receiver is
  empty, create an error notification."
+
  | lastObject |
+ firstIndex > lastIndex ifTrue: [ self errorEmptyCollection ].
- self emptyCheck.
  lastObject := array at: lastIndex.
  array at: lastIndex put: nil.
  lastIndex := lastIndex - 1.
  ^ lastObject!