#FEATURE by cg
class: OrderedCollection
comment/format in: #initContents:
changed:
#new
#new:
#newLikelyToRemainEmpty
--- a/OrderedCollection.st Wed Jun 15 11:53:40 2016 +0200
+++ b/OrderedCollection.st Wed Jun 15 12:02:42 2016 +0200
@@ -231,10 +231,7 @@
new
"create a new, empty OrderedCollection"
- MinContentsArraySize isNil ifTrue:[
- self initialize.
- ].
- ^ self basicNew initContents:MinContentsArraySize
+ ^ self basicNew initContents:0
"
self new
@@ -264,13 +261,7 @@
See also newWithSize:, which might do what you really want.
"
- |sz|
-
- MinContentsArraySize isNil ifTrue:[
- self initialize.
- ].
- sz := size.
- ^ self basicNew initContents:sz
+ ^ self basicNew initContents:size
"Modified: 19.3.1996 / 17:53:47 / cg"
!
@@ -310,13 +301,10 @@
"create a new, empty OrderedCollection, for which we already know
that it is very likely to remain empty.
Use this for collections which may sometimes get elements added, but usually not.
- This creates an initial contents array of size 0 in contrast to the default new:0,
- which preserves space for MinContentsArraySize (4) elements."
+ This is now obsolete and the same as new:
+ as the algorithm is now clever enough to deal efficiently with this situation"
- MinContentsArraySize isNil ifTrue:[
- self initialize.
- ].
- ^ self basicNew initContents:0
+ ^ self new:0
"
self newLikelyToRemainEmpty size
@@ -1721,7 +1709,7 @@
"setup the receiver-collection to hold size entries"
size == 0 ifTrue:[
- contentsArray := #(). "save garbage"
+ contentsArray := #(). "save memory by using a shared instance"
] ifFalse:[
contentsArray := Array basicNew:size.
].