MethodDictionary.st
changeset 23819 8803cc371eca
parent 22309 a48cd79a42a5
child 23821 f6440feca8f9
--- a/MethodDictionary.st	Sun Mar 03 11:27:12 2019 +0100
+++ b/MethodDictionary.st	Sun Mar 03 15:59:58 2019 +0100
@@ -17,7 +17,7 @@
 
 KeyedCollection variableSubclass:#MethodDictionary
 	instanceVariableNames:''
-	classVariableNames:''
+	classVariableNames:'EmptySingleton'
 	poolDictionaries:''
 	category:'Kernel-Methods'
 !
@@ -62,6 +62,22 @@
 
 !MethodDictionary class methodsFor:'instance creation'!
 
+new 
+    "create and return an empty methodDictionary.
+     Because mDicts cannot grow, we return a singleton
+     (if any selectors are added later, a new instance
+      will be created anyway).
+     Using a singleton will speed up dynamic creation of
+     new classes which will be filled in later"
+
+    EmptySingleton isNil ifTrue:[
+        EmptySingleton := super new.
+    ].    
+    ^ EmptySingleton
+
+    "Created: / 03-03-2019 / 15:27:43 / Claus Gittinger"
+!
+
 new:sz 
     "create and return a new methodDictionary holding sz
      key->value associations"