SequenceableCollection.st
changeset 4807 2991043fc36d
parent 4788 3dc29c8e6ca8
child 4855 d2abe6d95aa1
--- a/SequenceableCollection.st	Fri Sep 24 14:27:25 1999 +0200
+++ b/SequenceableCollection.st	Fri Sep 24 15:04:22 1999 +0200
@@ -75,6 +75,17 @@
 
 !SequenceableCollection class methodsFor:'instance creation'!
 
+decodeFromLiteralArray:anArray
+    "create & return a new instance from information encoded in anArray.
+     Redefined for faster creation.
+    "
+    |col|
+    col := self new.
+    anArray from:2 do:[:el| col add:(el decodeAsLiteralArray) ].
+  ^ col
+
+!
+
 new:size withAll:element
     "return a new collection of size, where all elements are
      initialized to element."
@@ -1335,12 +1346,17 @@
     "encode myself as an array literal, from which a copy of the receiver
      can be reconstructed with #decodeAsLiteralArray."
 
-    ^ (self collect:[:el | el literalArrayEncoding]) asArray
+    |encoding|
+
+    encoding := OrderedCollection with:(self class name).
+    self do:[:el| encoding add:(el literalArrayEncoding) ].
+  ^ encoding asArray
+
 
     "
      (Array with:(Color red:50 green:50 blue:50)
             with:(1 @ 2)
-     ) literalArrayEncoding   
+     ) literalArrayEncoding decodeAsLiteralArray  
     "
 
     "Modified: 22.4.1996 / 13:00:56 / cg"
@@ -4400,6 +4416,6 @@
 !SequenceableCollection class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/SequenceableCollection.st,v 1.117 1999-09-22 15:38:49 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/SequenceableCollection.st,v 1.118 1999-09-24 13:03:40 cg Exp $'
 ! !
 SequenceableCollection initialize!