[Pkg] The Trunk: EToys-kfr.330.mcz

commits at source.squeak.org commits at source.squeak.org
Sat May 26 09:55:43 UTC 2018

Karl Ramberg uploaded a new version of EToys to project The Trunk:

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

Name: EToys-kfr.330
Author: kfr
Time: 26 May 2018, 11:55:21.200868 am
UUID: 6d9d29a4-708f-e540-a815-584b7d42115e
Ancestors: EToys-mt.329

Player had a send to deprecated Smalltalk>>removeKey:ifAbsent:

=============== Diff against EToys-mt.329 ===============

Item was changed:
  ----- Method: Player class>>freeUnreferencedSubclasses (in category 'housekeeping') -----
  	"Player classes may hold in their class instance variables references
  to instances of themselves that are housekeepingwise unreachable. This
  method allows such loops to be garbage collected. This is done in three
  	1. Remove user-created subclasses from the 'subclasses' set and from
  Smalltalk. Only remove classes whose name begins with 'Player' and which
  have no references.
  	2. Do a full garbage collection.
  	3. Enumerate all Metaclasses and find those whose soleInstance's
  superclass is this class. Reset the subclasses set to this set of
  classes, and add back to Smalltalk."
  	"Player freeUnreferencedSubclasses"
  	| oldFree candidatesForRemoval class |
  	oldFree := Smalltalk garbageCollect.
  	candidatesForRemoval := self subclasses asOrderedCollection select:
  		[:aClass | (aClass name beginsWith: 'Player') and: [aClass name
  	"Break all system links and then perform garbage collection."
  	candidatesForRemoval do:
  		[:c | self removeSubclass: c.  "Break downward subclass pointers."
+ 		Smalltalk globals removeKey: c name ifAbsent: [].  "Break binding of global
- 		Smalltalk removeKey: c name ifAbsent: [].  "Break binding of global
  	candidatesForRemoval := nil.
  	Smalltalk garbageCollect.  "Now this should reclaim all unused
  	"Now reconstruct system links to subclasses with valid references."
  	"First restore any global references via associations"
  	(Association allSubInstances select:
  			[:assn | (assn key isSymbol)
  					and: [(assn key beginsWith: 'Player')
  					and: [assn key endsWithDigit]]])
  		do: [:assn | class := assn value.
  			(class isKindOf: self class) ifTrue:
  				[self addSubclass: class.
  				Smalltalk add: assn]].
  	"Then restore any further direct references, creating new
  	(Metaclass allInstances select:
  			[:m | (m soleInstance name beginsWith: 'Player')
  					and: [m soleInstance name endsWithDigit]])
  		do: [:m | class := m soleInstance.
  			((class isKindOf: self class) and: [(Smalltalk includesKey: class
  name) not]) ifTrue:
  				[self addSubclass: class.
  				Smalltalk at: class name put: class]].
  	SystemOrganization removeMissingClasses.
  	^ Smalltalk garbageCollect - oldFree

More information about the Packages mailing list