On Tue, 14 Jul 2009 01:47:51 +0200
Nicolas Petton <[email protected]> wrote:

> I already added Iliad.Id>>printOn:, just update :)

Well, I did ... and while looking at the diffs I noticed 
Iliad.Id table for the first time.

It is implemented on the instance side and builds the array
with the character pool, from which the random ids (themselves a
subclass of ByteArray) are built. And it is called quite often
when constructing an id.

ste...@g128 iliad $ gst
GNU Smalltalk ready

st> PackageLoader fileInPackage: 'Iliad'
...
st> Time millisecondsToRun: [ 10000 timesRepeat: [Iliad.Id new ] ]
3086
st> Time millisecondsToRun: [ 10000 timesRepeat: [Iliad.Id new ] ]
3087
st> 

code code clickty click ...

ste...@g128 iliad $ gst
GNU Smalltalk ready

st> PackageLoader fileInPackage: 'Iliad'
st> Time millisecondsToRun: [ 10000 timesRepeat: [Iliad.Id new ] ]
384
st> Time millisecondsToRun: [ 10000 timesRepeat: [Iliad.Id new ] ]
383

off to work,
s.
Index: Core/Utilities/Id.st
===================================================================
--- Core/Utilities/Id.st	(revision 1402)
+++ Core/Utilities/Id.st	(working copy)
@@ -4,21 +4,37 @@
     <comment: nil>
     <category: 'Iliad-Core-Utilities'>
 
-    Id class >> defaultSize [
-	<category: 'defaults'>
-	^32
-    ]
+    Id class [
 
-    Id class >> new [
-	<category: 'instance creation'>
-	^self new: self defaultSize
-    ]
+        | table |
 
-    Id class >> new: anInteger [
-	<category: 'instance creation'>
-	^(self basicNew: anInteger)
-	    initialize;
-	    yourself
+        defaultSize [
+            <category: 'defaults'>
+            ^32
+        ]
+
+        new [
+            <category: 'instance creation'>
+            ^self new: self defaultSize
+        ]
+
+        new: anInteger [
+            <category: 'instance creation'>
+            ^(self basicNew: anInteger)
+                initialize;
+                yourself
+        ]
+
+        table [
+            <category: 'accessing'>
+            ^ table ifNil: [ table := self defaultTable ]
+        ]
+
+        defaultTable [ 
+            <category: 'defaults'>
+            ^($a to: $z) , ($0 to: $9) , (Array with: $_ with: $-) 
+        ]
+    
     ]
 
     initialize [
@@ -31,7 +47,7 @@
 
     table [
 	<category: 'accessing'>
-	^($a to: $z) , ($0 to: $9) , (Array with: $_ with: $-)
+	^ self class table
     ]
 
     printOn: aStream [

Attachment: signature.asc
Description: PGP signature

_______________________________________________
help-smalltalk mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/help-smalltalk

Reply via email to