Object.st
changeset 19272 07c01cb9c96f
parent 18984 a811aef4aaf5
child 19280 97f4b4141f82
child 19287 7e945c7dc124
--- a/Object.st	Tue Mar 01 10:26:25 2016 +0100
+++ b/Object.st	Tue Mar 01 17:14:01 2016 +0100
@@ -2424,58 +2424,60 @@
      The variable slots are copied as available
      (i.e. the min of both indexed sizes is used)."
 
-    |myClass prototypesClass myInfo prototypesInfo|
-
+    |myClass prototypesClass myInfo prototypesInfo 
+     sz "{ Class: SmallInteger }"|
 
     myClass := self class.
     prototypesClass := aPrototype class.
     (myClass == prototypesClass
-    or:[ myClass isSubclassOf:prototypesClass ]) ifTrue:[
-	"/ can do better, if my class is a subclass of the prototype's class
-	1 to: prototypesClass instSize do:[:index |
-	    self instVarAt:index put:(aPrototype instVarAt:index)
-	]
+     or:[myClass isSubclassOf:prototypesClass]) ifTrue:[
+        "/ can do better, if my class is a subclass of the prototype's class
+        sz := prototypesClass instSize.
+        1 to: sz do:[:index |
+            self instVarAt:index put:(aPrototype instVarAt:index)
+        ]
     ] ifFalse:[
-	"/ map instvars by name
-	myInfo := myClass instanceVariableOffsets.
-	prototypesInfo := prototypesClass instanceVariableOffsets.
-	myInfo keysAndValuesDo:[:name :index | |varIndexAssoc|
-	    varIndexAssoc := prototypesInfo at:name ifAbsent:[].
-	    varIndexAssoc notNil ifTrue:[
-		self instVarAt:index put:(aPrototype instVarAt:(varIndexAssoc value))
-	    ]
-	]
+        "/ map instvars by name
+        myInfo := myClass instanceVariableOffsets.
+        prototypesInfo := prototypesClass instanceVariableOffsets.
+        myInfo keysAndValuesDo:[:name :index | |varIndexAssoc|
+            varIndexAssoc := prototypesInfo at:name ifAbsent:[].
+            varIndexAssoc notNil ifTrue:[
+                self instVarAt:index put:(aPrototype instVarAt:(varIndexAssoc value))
+            ]
+        ]
     ].
     myClass isVariable ifTrue:[
-	prototypesClass isVariable ifTrue:[
-	    1 to:(self basicSize min:aPrototype basicSize) do:[:index |
-		self basicAt:index put:(aPrototype basicAt:index)
-	    ].
-	].
+        prototypesClass isVariable ifTrue:[
+            sz := self basicSize min:aPrototype basicSize.
+            1 to:sz do:[:index |
+                self basicAt:index put:(aPrototype basicAt:index)
+            ].
+        ].
     ].
 
     "
      Class withoutUpdatingChangesDo:[
-	|point3D|
-
-	point3D := Point subclass:#Point3D
-	   instanceVariableNames:'z'
-	   classVariableNames:''
-	   poolDictionaries:''
-	   category:'testing'
-	   inEnvironment:nil.
-	 (point3D new cloneInstanceVariablesFrom:1@2) inspect.
+        |point3D|
+
+        point3D := Point subclass:#Point3D
+           instanceVariableNames:'z'
+           classVariableNames:''
+           poolDictionaries:''
+           category:'testing'
+           inEnvironment:nil.
+         (point3D new cloneInstanceVariablesFrom:1@2) inspect.
      ]
     "
 
     "
      Class withoutUpdatingChangesDo:[
-	 Point variableSubclass:#Point3D_test
-	   instanceVariableNames:'z'
-	   classVariableNames:''
-	   poolDictionaries:''
-	   category:'testing'.
-	 (((Smalltalk at:#Point3D_test) new:2) cloneInstanceVariablesFrom:#(1 2 3)) inspect.
+         Point variableSubclass:#Point3D_test
+           instanceVariableNames:'z'
+           classVariableNames:''
+           poolDictionaries:''
+           category:'testing'.
+         (((Smalltalk at:#Point3D_test) new:2) cloneInstanceVariablesFrom:#(1 2 3)) inspect.
      ]
     "
 
@@ -2483,19 +2485,19 @@
      |someObject|
 
      Class withoutUpdatingChangesDo:[
-	 Object subclass:#TestClass1
-	   instanceVariableNames:'foo bar'
-	   classVariableNames:''
-	   poolDictionaries:''
-	   category:'testing'.
-	 someObject := TestClass1 new.
-	 someObject instVarAt:1 put:'foo'; instVarAt:2 put:'bar'.
-	 Object subclass:#TestClass2
-	   instanceVariableNames:'bar foo'
-	   classVariableNames:''
-	   poolDictionaries:''
-	   category:'testing'.
-	 (TestClass2 new cloneInstanceVariablesFrom:someObject) inspect.
+         Object subclass:#TestClass1
+           instanceVariableNames:'foo bar'
+           classVariableNames:''
+           poolDictionaries:''
+           category:'testing'.
+         someObject := TestClass1 new.
+         someObject instVarAt:1 put:'foo'; instVarAt:2 put:'bar'.
+         Object subclass:#TestClass2
+           instanceVariableNames:'bar foo'
+           classVariableNames:''
+           poolDictionaries:''
+           category:'testing'.
+         (TestClass2 new cloneInstanceVariablesFrom:someObject) inspect.
      ]
     "