Speed aup #literalArrayEncoding
authorStefan Vogel <sv@exept.de>
Wed, 03 Sep 2003 17:54:12 +0200
changeset 7598 27f37bd56675
parent 7597 db72d9d640bc
child 7599 188489aaaacd
Speed aup #literalArrayEncoding
SequenceableCollection.st
Set.st
--- a/SequenceableCollection.st	Sun Aug 31 10:37:25 2003 +0200
+++ b/SequenceableCollection.st	Wed Sep 03 17:54:12 2003 +0200
@@ -2055,11 +2055,16 @@
     "encode myself as an array literal, from which a copy of the receiver
      can be reconstructed with #decodeAsLiteralArray."
 
-    |encoding|
-
-    encoding := OrderedCollection with:(self class name).
-    self do:[:el| encoding add:(el literalArrayEncoding) ].
-  ^ encoding asArray
+    |encoding idx|
+
+    encoding := Array new:self size + 1.
+    encoding at:1 put:self class name.
+    idx := 2.
+    self do:[:element| 
+        encoding at:idx put:element literalArrayEncoding.
+        idx := idx + 1.
+    ].
+    ^ encoding
 
 
     "
@@ -6140,7 +6145,7 @@
 !SequenceableCollection class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/SequenceableCollection.st,v 1.195 2003-08-05 09:49:06 stefan Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/SequenceableCollection.st,v 1.196 2003-09-03 15:54:12 stefan Exp $'
 ! !
 
 SequenceableCollection initialize!
--- a/Set.st	Sun Aug 31 10:37:25 2003 +0200
+++ b/Set.st	Wed Sep 03 17:54:12 2003 +0200
@@ -190,8 +190,6 @@
     "Created: / 24.10.1997 / 23:13:44 / cg"
 ! !
 
-
-
 !Set methodsFor:'Compatibility-ST80'!
 
 initialIndexFor:hashKey boundedBy:length
@@ -567,17 +565,22 @@
     "encode myself as an array literal, from which a copy of the receiver
      can be reconstructed with #decodeAsLiteralArray."
 
-    |encoding|
+    |encoding idx|
 
-    encoding := OrderedCollection with:(self class name).
-    self do:[:el| encoding add:(el literalArrayEncoding) ].
-  ^ encoding asArray
+    encoding := Array new:self size + 1.
+    encoding at:1 put:self class name.
+    idx := 2.
+    self do:[:element| 
+        encoding at:idx put:element literalArrayEncoding.
+        idx := idx + 1.
+    ].
+    ^ encoding
 
 
     "
      (Set with:1234
-	  with:(1 @ 2)
-	  with:'hello'
+          with:(1 @ 2)
+          with:'hello'
      ) literalArrayEncoding decodeAsLiteralArray  
     "
 
@@ -1098,7 +1101,7 @@
 !Set class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/Set.st,v 1.86 2003-05-19 18:40:02 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/Set.st,v 1.87 2003-09-03 15:53:29 stefan Exp $'
 ! !
 
 Set initialize!