# HG changeset patch # User Stefan Vogel # Date 1195665818 -3600 # Node ID 5408c171f52fcf220b6d31f35c05c010cae6a3a1 # Parent 08a9ee8cf3178a2e4598a75621b9c564da532445 speed up #addAll: diff -r 08a9ee8cf317 -r 5408c171f52f ArrayedCollection.st --- a/ArrayedCollection.st Wed Nov 21 11:10:11 2007 +0100 +++ b/ArrayedCollection.st Wed Nov 21 18:23:38 2007 +0100 @@ -9,7 +9,6 @@ other person. No title to or ownership of the software is hereby transferred. " - "{ Package: 'stx:libbasic' }" SequenceableCollection subclass:#ArrayedCollection @@ -306,6 +305,30 @@ ^ self == ArrayedCollection ! ! +!ArrayedCollection methodsFor:'adding'! + +addAll:aCollection + "add all elements of the argument, aCollection to the receiver. + Returns the argument, aCollection (sigh). + + Redefined here, to perform only a single slow grow operation" + + |mySize| + + mySize := self size. + self grow:mySize + aCollection size. + + aCollection do:[:element | + mySize := mySize + 1. + self at:mySize put:element + ]. + ^ aCollection + + " + #(1 2 3 4) addAll:#(5 6 7 8); yourself + " +! ! + !ArrayedCollection methodsFor:'copying'! copyEmptyAndGrow:size @@ -456,5 +479,5 @@ !ArrayedCollection class methodsFor:'documentation'! version - ^ '$Header: /cvs/stx/stx/libbasic/ArrayedCollection.st,v 1.55 2006-01-31 22:27:02 cg Exp $' + ^ '$Header: /cvs/stx/stx/libbasic/ArrayedCollection.st,v 1.56 2007-11-21 17:23:38 stefan Exp $' ! !