Collection.st
changeset 23536 a92d5817bb84
parent 23535 ffe068c98121
child 23566 48dd181b12f0
--- a/Collection.st	Fri Nov 16 12:22:02 2018 +0100
+++ b/Collection.st	Sat Nov 17 02:34:59 2018 +0100
@@ -16,11 +16,11 @@
 "{ NameSpace: Smalltalk }"
 
 Object subclass:#Collection
-	instanceVariableNames:''
-	classVariableNames:'EmptyCollectionSignal InvalidKeySignal NotEnoughElementsSignal
-		ValueNotFoundSignal'
-	poolDictionaries:''
-	category:'Collections-Abstract'
+        instanceVariableNames:''
+        classVariableNames:'EmptyCollectionSignal InvalidKeySignal NotEnoughElementsSignal
+                ValueNotFoundSignal'
+        poolDictionaries:''
+        category:'Collections-Abstract'
 !
 
 !Collection class methodsFor:'documentation'!
@@ -2529,7 +2529,7 @@
 
     |newCollection|
 
-    newCollection := self speciesForCollecting new:self size.
+    newCollection := self speciesForCollecting newWithCapacity:self size.
     self do:[:element | newCollection add:(aBlockOrSymbol value:element)].
     ^ newCollection
 
@@ -2539,6 +2539,7 @@
     "
 
     "Modified (comment): / 20-09-2017 / 19:39:22 / stefan"
+    "Modified: / 16-11-2018 / 12:20:42 / Claus Gittinger"
 !
 
 collect:aBlockOrSymbol as:aClass
@@ -4364,7 +4365,7 @@
 
     |newCollection|
 
-    newCollection := self speciesForCollecting new.
+    newCollection := self speciesForCollecting newWithCapacity:(self size).
     self keysAndValuesDo:[:key :value |
         newCollection add:(aTwoArgBlock value:value value:key)
     ].
@@ -4374,6 +4375,8 @@
      #(one two three) withIndexCollect:[:sym :num | (num->sym)] 
      #(10 20 30) withIndexCollect:[:n :i | n*i ]  
     "
+
+    "Modified: / 16-11-2018 / 12:41:44 / Claus Gittinger"
 !
 
 withIndexDo:aTwoArgBlock