The Trunk: Collections-ul.922.mcz

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

The Trunk: Collections-ul.922.mcz

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

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

Name: Collections-ul.922
Author: ul
Time: 19 January 2021, 1:28:51.784086 pm
UUID: 7d688371-2966-43d3-9000-3985ae9f6afa
Ancestors: Collections-nice.921

Fix off-by-one errors in OrderedCollection's #removeFirst: and #removeLast:. The argument of those methods can be zero.

=============== Diff against Collections-nice.921 ===============

Item was changed:
  ----- Method: OrderedCollection>>removeFirst: (in category 'removing') -----
  removeFirst: n
  "Remove the first n objects into an array."
 
  | lastIndexToRemove result |
+ n < 0 ifTrue: [ self errorNoSuchElement ].
- n < 1 ifTrue: [ self errorNoSuchElement ].
  lastIndex < (lastIndexToRemove := firstIndex + n - 1) ifTrue: [ self errorNotEnoughElements ].
  result := array copyFrom: firstIndex to: lastIndexToRemove.
  array from: firstIndex to: lastIndexToRemove put: nil.
  firstIndex := lastIndexToRemove + 1.
  ^result!

Item was changed:
  ----- Method: OrderedCollection>>removeLast: (in category 'removing') -----
  removeLast: n
  "Remove the last n objects into an array with last in last position."
 
  | firstIndexToRemove result |
+ n < 0 ifTrue: [ self errorNoSuchElement ].
- n < 1 ifTrue: [ self errorNoSuchElement ].
  (firstIndexToRemove := lastIndex - n + 1) < firstIndex ifTrue: [ self errorNotEnoughElements ].
  result := array copyFrom: firstIndexToRemove to: lastIndex.
  array from: firstIndexToRemove to: lastIndex put: nil.
  lastIndex := firstIndexToRemove - 1.
  ^result!


Reply | Threaded
Open this post in threaded view
|

Re: The Trunk: Collections-ul.922.mcz

Eliot Miranda-2


On Tue, Jan 19, 2021 at 4:31 AM <[hidden email]> wrote:
Levente Uzonyi uploaded a new version of Collections to project The Trunk:
http://source.squeak.org/trunk/Collections-ul.922.mcz

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

Name: Collections-ul.922
Author: ul
Time: 19 January 2021, 1:28:51.784086 pm
UUID: 7d688371-2966-43d3-9000-3985ae9f6afa
Ancestors: Collections-nice.921

Fix off-by-one errors in OrderedCollection's #removeFirst: and #removeLast:. The argument of those methods can be zero.

Thanks!!

Name: RoelTyper-eem.88
Author: eem
Time: 19 January 2021, 1:33:32.686379 pm
UUID: 7cba406e-2ec5-4798-8046-e41bf4bd0388
Ancestors: RoelTyper-eem.87

Revert the work-around in InstvarInterfaceExtractor>>nativeSend:numArgs: now that Collections-ul.922 fixes the issues with anOrderedColleciton removeLast: 0.


=============== Diff against Collections-nice.921 ===============

Item was changed:
  ----- Method: OrderedCollection>>removeFirst: (in category 'removing') -----
  removeFirst: n
        "Remove the first n objects into an array."

        | lastIndexToRemove result |
+       n < 0 ifTrue: [ self errorNoSuchElement ].
-       n < 1 ifTrue: [ self errorNoSuchElement ].
        lastIndex < (lastIndexToRemove := firstIndex + n - 1) ifTrue: [ self errorNotEnoughElements ].
        result := array copyFrom: firstIndex to: lastIndexToRemove.
        array from: firstIndex to: lastIndexToRemove put: nil.
        firstIndex := lastIndexToRemove + 1.
        ^result!

Item was changed:
  ----- Method: OrderedCollection>>removeLast: (in category 'removing') -----
  removeLast: n
        "Remove the last n objects into an array with last in last position."

        | firstIndexToRemove result |
+       n < 0 ifTrue: [ self errorNoSuchElement ].
-       n < 1 ifTrue: [ self errorNoSuchElement ].
        (firstIndexToRemove := lastIndex - n + 1) < firstIndex ifTrue: [ self errorNotEnoughElements ].
        result := array copyFrom: firstIndexToRemove to: lastIndex.
        array from: firstIndexToRemove to: lastIndex put: nil.
        lastIndex := firstIndexToRemove - 1.
        ^result!




--
_,,,^..^,,,_
best, Eliot