[Pkg] The Trunk: Kernel-pre.1125.mcz

commits at source.squeak.org commits at source.squeak.org
Mon Nov 27 16:13:14 UTC 2017


Patrick Rein uploaded a new version of Kernel to project The Trunk:
http://source.squeak.org/trunk/Kernel-pre.1125.mcz

==================== Summary ====================

Name: Kernel-pre.1125
Author: pre
Time: 27 November 2017, 5:13:00.494723 pm
UUID: 9e2716d1-e17d-1d4e-a6db-bdab28e189c8
Ancestors: Kernel-dtl.1124

Adds a comment for deepCopy to make the consequences regarding object identity explicit.

=============== Diff against Kernel-dtl.1124 ===============

Item was changed:
  ----- Method: Object>>deepCopy (in category 'copying') -----
  deepCopy
+ 	"Answer a copy of the receiver with its own copy of each instance variable.
+ 	WARNING: deepCopy does not preserve object identities in cycles in the object graph. Consider using #veryDeepCopy instead."
- 	"Answer a copy of the receiver with its own copy of each instance 
- 	variable."
  
  	| newObject class index |
  	class := self class.
  	(class == Object) ifTrue: [^self].
  	class isVariable
  		ifTrue: 
  			[index := self basicSize.
  			newObject := class basicNew: index.
  			[index > 0]
  				whileTrue: 
  					[newObject basicAt: index put: (self basicAt: index) deepCopy.
  					index := index - 1]]
  		ifFalse: [newObject := class basicNew].
  	index := class instSize.
  	[index > 0]
  		whileTrue: 
  			[newObject instVarAt: index put: (self instVarAt: index) deepCopy.
  			index := index - 1].
  	^newObject!

Item was changed:
  ----- Method: Object>>veryDeepCopy (in category 'copying') -----
  veryDeepCopy
+ 	"Do a complete tree copy using a dictionary. An object in the tree twice is only copied once. All references to the object in the copy of the tree will point to the new copy."
- 	"Do a complete tree copy using a dictionary.  An object in the tree twice is only copied once.  All references to the object in the copy of the tree will point to the new copy."
  
  	| copier new |
  	copier := DeepCopier new: self initialDeepCopierSize.
  	new := self veryDeepCopyWith: copier.
  	copier mapUniClasses.
  	copier references associationsDo: [:assoc | 
  		assoc value veryDeepFixupWith: copier].
  	copier fixDependents.
  	^ new!



More information about the Packages mailing list