Bug 40550

GemStone/S 64 Bit

2.4.2, 2.4.1, 2.4, 2.3.1.6, 2.3.1, 2.3, 2.2.5.4, 2.2.5.3, 2.2.5.2, 2.2.5.1, 2.2.5, 2.2.x, 2.2, 2.1.2, 2.1.x, 2.0.x, 1.2.4, 1.x

All

2.4.3

copyReplaceFrom:to:with: incorrect for empty with: argument

If the with: argument to SequenceableCollection >> copyReplaceFrom:to:with:
is an empty collection, this method incorrectly returned the receiver.

Workaround

File in the following as SystemUser and commit:

category: 'Copying'
method: SequenceableCollection
copyReplaceFrom: startIndex to: stopIndex with: aSequenceableCollection

    "Returns a copy of the receiver in which all elements in the
    receiver between indexes startIndex and stopIndex inclusive have
    been replaced by those contained in aSequenceableCollection."

    | selfSize seqCollSize targetIndex result |
    startIndex > stopIndex ifTrue:
        [^startIndex _error: #rtErrBadCopyFromTo args: #[stopIndex]].

    seqCollSize := aSequenceableCollection size.
    result := self species new.
    targetIndex := 1.

    startIndex > 1 ifTrue:
        [self
             copyFrom: 1
             to: startIndex - 1
             into: result
             startingAt: targetIndex.
         targetIndex := targetIndex + startIndex - 1].

        0 < seqCollSize ifTrue: [
                aSequenceableCollection
                        copyFrom: 1
                        to: seqCollSize
                        into: result
                        startingAt: targetIndex.
        ].
    targetIndex := targetIndex + seqCollSize.

    selfSize := self size.
    stopIndex < selfSize ifTrue:
        [self
             copyFrom: stopIndex + 1
             to: selfSize
             into: result
             startingAt: targetIndex].

    ^result
%


                

Last updated: 6/2/10