#REFACTORING by cg
authorClaus Gittinger <cg@exept.de>
Fri, 01 Mar 2019 16:05:38 +0100
changeset 23787 f8f3f03ef664
parent 23786 fee4d65305fd
child 23788 198291c346b3
#REFACTORING by cg class: ObjectMemory class changed: #displayRefChainToAny:limitNumberOfSearchedReferences: #refChainsFrom:to:inRefSets:startingAt:
ObjectMemory.st
--- a/ObjectMemory.st	Fri Mar 01 16:00:20 2019 +0100
+++ b/ObjectMemory.st	Fri Mar 01 16:05:38 2019 +0100
@@ -1451,29 +1451,29 @@
     lbl origin:(0.0@0.0) corner:(1.0@0.0).
     h := lbl preferredHeight.
     lbl
-	topInset:5;
-	bottomInset:(h+5) negated;
-	leftInset:5;
-	rightInset:5.
+        topInset:5;
+        bottomInset:(h+5) negated;
+        leftInset:5;
+        rightInset:5.
 
     progress := ProgressIndicator in:top.
     progress origin:(0.0@45) corner:(1.0@45).
     progress level:-1.
     h := progress preferredHeight.
     progress
-	topInset:(h // 2) negated;
-	bottomInset:(h // 2) negated;
-	leftInset:5;
-	rightInset:5.
+        topInset:(h // 2) negated;
+        bottomInset:(h // 2) negated;
+        leftInset:5;
+        rightInset:5.
     progress beInvisible.
 
     listV := HVScrollableView for:SelectionInListView in:top.
     listV origin:(0.0@55) corner:(1.0@1.0).
     listV
-	topInset:(h // 2);
-	bottomInset:40;
-	leftInset:5;
-	rightInset:5.
+        topInset:(h // 2);
+        bottomInset:40;
+        leftInset:5;
+        rightInset:5.
     listV beInvisible.
 
     panel := HorizontalPanelView in:top.
@@ -1512,259 +1512,259 @@
     firstRound := true.
 
     [done] whileFalse:[
-	anyShown := false.
-
-	progress percentage:0.
-	firstRound ifTrue:[
-	    firstRound := false.
-	] ifFalse:[
-	    lbl label:'compressing garbage ...'.
-	    self garbageCollect.
-	].
-
-	lbl label:('searching level '
-		   , levels size printString
-		   , ' (' , objects size printString , ' refs) ...').
-	nAll := objects size.
-	nDone := 0.
-
-	objectArray := objects asArray.
-
-	owners := "Weak"IdentitySet new.
-
-	numObjectsDone := 0.
-	found := false.
-
-	AbortOperationRequest catch:[
-	    self allObjectsIncludingContextsDo:[:o |
-		|inPrevLevel isOwner|
-
-		stop ifTrue:[AbortOperationRequest raise].
-		stop ifFalse:[
-		    isOwner := false.
-		    (o referencesAny:objectArray) ifTrue:[
-			o isBehavior ifTrue:[
-			    o == Smalltalk ifTrue:[
-				found := true.
-			    ] ifFalse:[
-				"/ only add it if it has classInstVars
-				o instSize ~~ Class instSize ifTrue:[
-				    isOwner := true.
-				]
-			    ]
-			] ifFalse:[
-			    o class ~~ WeakArray ifTrue:[
-				isOwner := true.
-			    ]
-			].
-		    ].
-
-		    isOwner ifTrue:[
-			(objects includesIdentical:o) ifFalse:[
-			    inPrevLevel := false.
-			    levels do:[:lColl |
-				lColl == o ifTrue:[
-				    inPrevLevel := true
-				] ifFalse:[
-				    (lColl includesIdentical:o) ifTrue:[inPrevLevel := true].
-				]
-			    ].
-			    inPrevLevel ifFalse:[
-				owners add:o.
-				(limitOrNil notNil and:[owners size >= limitOrNil]) ifTrue:[
-				    AbortOperationRequest raise
-				].
-			    ]
-			]
-		    ].
-
-		    numObjectsDone := numObjectsDone + 1.
-		    numObjects notNil ifTrue:[
-			numObjectsDone \\ 1000 == 0 ifTrue:[
-			    progress percentage:(numObjectsDone / numObjects * 100).
-			    Processor yield.
-			]
-		    ]
-		]
-	    ].
-	].
-	progress percentage:100.
-
-	numObjects isNil ifTrue:[
-	    numObjects := numObjectsDone.
-	].
-
-	owners remove:aCollection ifAbsent:nil.
-	owners remove:thisContext ifAbsent:nil.
-	owners remove:objectArray ifAbsent:nil.
-	owners remove:objects keyArray ifAbsent:nil.
-	owners remove:owners keyArray ifAbsent:nil.
+        anyShown := false.
+
+        progress percentage:0.
+        firstRound ifTrue:[
+            firstRound := false.
+        ] ifFalse:[
+            lbl label:'compressing garbage ...'.
+            self garbageCollect.
+        ].
+
+        lbl label:('searching level '
+                   , levels size printString
+                   , ' (' , objects size printString , ' refs) ...').
+        nAll := objects size.
+        nDone := 0.
+
+        objectArray := objects asArray.
+
+        owners := "Weak"IdentitySet new.
+
+        numObjectsDone := 0.
+        found := false.
+
+        AbortOperationRequest catch:[
+            self allObjectsIncludingContextsDo:[:o |
+                |inPrevLevel isOwner|
+
+                stop ifTrue:[AbortOperationRequest raise].
+                stop ifFalse:[
+                    isOwner := false.
+                    (o referencesAny:objectArray) ifTrue:[
+                        o isBehavior ifTrue:[
+                            o == Smalltalk ifTrue:[
+                                found := true.
+                            ] ifFalse:[
+                                "/ only add it if it has classInstVars
+                                o instSize ~~ Class instSize ifTrue:[
+                                    isOwner := true.
+                                ]
+                            ]
+                        ] ifFalse:[
+                            o class ~~ WeakArray ifTrue:[
+                                isOwner := true.
+                            ]
+                        ].
+                    ].
+
+                    isOwner ifTrue:[
+                        (objects includesIdentical:o) ifFalse:[
+                            inPrevLevel := false.
+                            levels do:[:lColl |
+                                lColl == o ifTrue:[
+                                    inPrevLevel := true
+                                ] ifFalse:[
+                                    (lColl includesIdentical:o) ifTrue:[inPrevLevel := true].
+                                ]
+                            ].
+                            inPrevLevel ifFalse:[
+                                owners add:o.
+                                (limitOrNil notNil and:[owners size >= limitOrNil]) ifTrue:[
+                                    AbortOperationRequest raise
+                                ].
+                            ]
+                        ]
+                    ].
+
+                    numObjectsDone := numObjectsDone + 1.
+                    numObjects notNil ifTrue:[
+                        numObjectsDone \\ 1000 == 0 ifTrue:[
+                            progress percentage:(numObjectsDone / numObjects * 100).
+                            Processor yield.
+                        ]
+                    ]
+                ]
+            ].
+        ].
+        progress percentage:100.
+
+        numObjects isNil ifTrue:[
+            numObjects := numObjectsDone.
+        ].
+
+        owners remove:aCollection ifAbsent:nil.
+        owners remove:thisContext ifAbsent:nil.
+        owners remove:objectArray ifAbsent:nil.
+        owners remove:objects keyArray ifAbsent:nil.
+        owners remove:owners keyArray ifAbsent:nil.
 
 "/ 'done with level: ' print. levels size print. ' found ' print. owners size print. ' refs' printCR.
 
-	owners isEmpty ifTrue:[
-	    found ifFalse:[
-		stop := true.
-	    ]
-	].
-
-	stop ifFalse:[
-	    done := found or:[(owners includesIdentical:Smalltalk)].
-	    done ifTrue:[
-		moreChainsOnThisLevel := true.
-		temporaryRemoved := IdentitySet new.
-
-		levels size > 0 ifTrue:[
-		    "/ show what we found so far.
-		    levels last add:Smalltalk.
-		    levels reverse.
-		].
-
-		chains := OrderedCollection new.
-
-		tLevels := levels collect:[:lColl | lColl copy].
-
-		lbl label:('building refchains ...').
-
-		nAll := aCollection size.
-		nDone := 0.
-		aCollection do:[:anObject | |theseChains|
-		    stop ifFalse:[
-			theseChains := self
-				refChainsFrom:Smalltalk
-				to:anObject
-				inRefSets:tLevels
-				startingAt:1.
-
-			theseChains size > 0 ifTrue:[
-			    chains addAll:theseChains
-			].
-			nDone := nDone + 1.
-			progress percentage:(nDone / nAll * 100).
-		    ]
-		].
-
-		tLevels := nil.
-
-		levels size > 0 ifTrue:[
-		    levels reverse.
-		    levels last remove:Smalltalk.
-		].
-
-		[stop not
-		 and:[chains size > 0]] whileTrue:[
-		    chain := chains first.
-		    chains removeFirst.
-
-		    lbl label:('Found a reference chain.').
-		    progress beInvisible.
-
-		    chain addFirst:Smalltalk.
-		    list := OrderedCollection newWithSize:chain size.
-		    1 to:chain size-1 do:[:i |
-			list
-			    at:i
-			    put:(self refNameFor:(chain at:i+1) in:(chain at:i))
-		    ].
-		    list at:list size put:(chain last class nameWithArticle).
-
-		    "/ hide the VMProcesses stuff from the user ...
-		    (list at:1) string = 'Smalltalk:__VMProcesses__' ifTrue:[
-			list at:1 put:'__VMProcesses__ (a hidden VM reference)'.
-			list removeIndex:2.
-			chain at:1 put:nil.
-			chain removeIndex:2.
-		    ].
-
-		    listV list:list.
-
-		    listV beVisible.
-		    listV
-			doubleClickAction:[:idx |
-			    |o key idxOfColon mayBeClassName mayBeClassVarName cls|
-
-			    (o := chain at:idx) notNil ifTrue:[
-				key := (list at:idx) string.
-				(key includes:$:) ifTrue:[
-				    idxOfColon := key lastIndexOf:$:.
-				    mayBeClassName := key copyTo:idxOfColon-1.
-				    mayBeClassVarName := key copyFrom:idxOfColon+1.
-				    (cls := Smalltalk classNamed:mayBeClassName) notNil ifTrue:[
-					o := cls
-				    ].
-				].
-				o inspect.
-			    ]
-			].
-		    moreButton beVisible.
-		    anyShown := anyShownInAnyLevel := true.
-		    showMore := false.
-
-		    "/ kludge - wait for some user action
-
-		    delay := Delay forSeconds:0.1.
-		    [showMore or:[stop or:[top realized not]]] whileFalse:[
-			delay wait.
-		    ].
-
-		    chain := nil.
-
-		    top realized ifFalse:[
-			stop := true
-		    ] ifTrue:[
-			listV doubleClickAction:nil.
-			showMore ifFalse:[
-			    stop := true.
-			].
-		    ].
-		    done := false.
-
-		    stop ifFalse:[
-			progress beVisible.
-			listV beInvisible.
-			moreButton beInvisible.
-
-			chain := nil.
-		    ]
-		].
-		levels size > 0 ifTrue:[
-		    levels last addAll:temporaryRemoved.
-		]
-	    ].
-	].
-
-	owners remove:Smalltalk ifAbsent:nil.
-	owners remove:(owners keyArray) ifAbsent:nil.
-	owners remove:objectArray ifAbsent:nil.
-	levels do:[:lColl |
-	    owners remove:lColl ifAbsent:nil
-	].
-
-	levels add:owners.
-
-	objects := owners.
-
-	objects size == 0 ifTrue:[
-	    stop := true
-	].
-
-	stop ifTrue:[
-	    Smalltalk at:#'__VMProcesses__' put:nil.
-	    top destroy.
-	    anyShown ifFalse:[
-		userStop ifFalse:[
-		    self information:(anyShownInAnyLevel ifTrue:['no more references'] ifFalse:['no references']).
-		]
-	    ].
-	   ^ self.
-	].
+        owners isEmpty ifTrue:[
+            found ifFalse:[
+                stop := true.
+            ]
+        ].
+
+        stop ifFalse:[
+            done := found or:[(owners includesIdentical:Smalltalk)].
+            done ifTrue:[
+                moreChainsOnThisLevel := true.
+                temporaryRemoved := IdentitySet new.
+
+                levels size ~~ 0 ifTrue:[
+                    "/ show what we found so far.
+                    levels last add:Smalltalk.
+                    levels reverse.
+                ].
+
+                chains := OrderedCollection new.
+
+                tLevels := levels collect:[:lColl | lColl copy].
+
+                lbl label:('building refchains ...').
+
+                nAll := aCollection size.
+                nDone := 0.
+                aCollection do:[:anObject | |theseChains|
+                    stop ifFalse:[
+                        theseChains := self
+                                refChainsFrom:Smalltalk
+                                to:anObject
+                                inRefSets:tLevels
+                                startingAt:1.
+
+                        theseChains size ~~ 0 ifTrue:[
+                            chains addAll:theseChains
+                        ].
+                        nDone := nDone + 1.
+                        progress percentage:(nDone / nAll * 100).
+                    ]
+                ].
+
+                tLevels := nil.
+
+                levels size ~~ 0 ifTrue:[
+                    levels reverse.
+                    levels last remove:Smalltalk.
+                ].
+
+                [stop not
+                 and:[chains size ~~ 0]] whileTrue:[
+                    chain := chains first.
+                    chains removeFirst.
+
+                    lbl label:('Found a reference chain.').
+                    progress beInvisible.
+
+                    chain addFirst:Smalltalk.
+                    list := OrderedCollection newWithSize:chain size.
+                    1 to:chain size-1 do:[:i |
+                        list
+                            at:i
+                            put:(self refNameFor:(chain at:i+1) in:(chain at:i))
+                    ].
+                    list at:list size put:(chain last class nameWithArticle).
+
+                    "/ hide the VMProcesses stuff from the user ...
+                    (list at:1) string = 'Smalltalk:__VMProcesses__' ifTrue:[
+                        list at:1 put:'__VMProcesses__ (a hidden VM reference)'.
+                        list removeIndex:2.
+                        chain at:1 put:nil.
+                        chain removeIndex:2.
+                    ].
+
+                    listV list:list.
+
+                    listV beVisible.
+                    listV
+                        doubleClickAction:[:idx |
+                            |o key idxOfColon mayBeClassName mayBeClassVarName cls|
+
+                            (o := chain at:idx) notNil ifTrue:[
+                                key := (list at:idx) string.
+                                (key includes:$:) ifTrue:[
+                                    idxOfColon := key lastIndexOf:$:.
+                                    mayBeClassName := key copyTo:idxOfColon-1.
+                                    mayBeClassVarName := key copyFrom:idxOfColon+1.
+                                    (cls := Smalltalk classNamed:mayBeClassName) notNil ifTrue:[
+                                        o := cls
+                                    ].
+                                ].
+                                o inspect.
+                            ]
+                        ].
+                    moreButton beVisible.
+                    anyShown := anyShownInAnyLevel := true.
+                    showMore := false.
+
+                    "/ kludge - wait for some user action
+
+                    delay := Delay forSeconds:0.1.
+                    [showMore or:[stop or:[top realized not]]] whileFalse:[
+                        delay wait.
+                    ].
+
+                    chain := nil.
+
+                    top realized ifFalse:[
+                        stop := true
+                    ] ifTrue:[
+                        listV doubleClickAction:nil.
+                        showMore ifFalse:[
+                            stop := true.
+                        ].
+                    ].
+                    done := false.
+
+                    stop ifFalse:[
+                        progress beVisible.
+                        listV beInvisible.
+                        moreButton beInvisible.
+
+                        chain := nil.
+                    ]
+                ].
+                levels size ~~ 0 ifTrue:[
+                    levels last addAll:temporaryRemoved.
+                ]
+            ].
+        ].
+
+        owners remove:Smalltalk ifAbsent:nil.
+        owners remove:(owners keyArray) ifAbsent:nil.
+        owners remove:objectArray ifAbsent:nil.
+        levels do:[:lColl |
+            owners remove:lColl ifAbsent:nil
+        ].
+
+        levels add:owners.
+
+        objects := owners.
+
+        objects size == 0 ifTrue:[
+            stop := true
+        ].
+
+        stop ifTrue:[
+            Smalltalk at:#'__VMProcesses__' put:nil.
+            top destroy.
+            anyShown ifFalse:[
+                userStop ifFalse:[
+                    self information:(anyShownInAnyLevel ifTrue:['no more references'] ifFalse:['no references']).
+                ]
+            ].
+           ^ self.
+        ].
 
     ].
 
     anyShown ifTrue:[
-	userStop ifFalse:[
-	    self information:'no more references'.
-	]
+        userStop ifFalse:[
+            self information:'no more references'.
+        ]
     ].
     Smalltalk at:#'__VMProcesses__' put:nil.
     ^ self
@@ -1814,7 +1814,7 @@
     "Created: / 02-02-1998 / 23:58:04 / cg"
     "Modified: / 10-07-1998 / 17:22:06 / cg"
     "Modified: / 21-02-2017 / 09:49:40 / stefan"
-    "Modified: / 01-08-2018 / 13:31:17 / Claus Gittinger"
+    "Modified: / 01-03-2019 / 16:04:48 / Claus Gittinger"
 !
 
 dumpObject:someObject
@@ -1976,35 +1976,36 @@
      chains := OrderedCollection new.
 
      index > levels size ifTrue:[
-	(start referencesObject:anObject) ifTrue:[
-	    chains add:(OrderedCollection with:anObject "(self refNameFor:anObject in:start)").
-	].
-	^ chains
+        (start referencesObject:anObject) ifTrue:[
+            chains add:(OrderedCollection with:anObject "(self refNameFor:anObject in:start)").
+        ].
+        ^ chains
      ].
 
      (levels at:index) do:[:el |
 el ~~ start ifTrue:[
-	(start referencesObject:el) ifTrue:[
-	    chain := self
-			refChainFrom:el
-			to:anObject
-			inRefSets:levels
-			startingAt:(index+1).
-
-	    chain size > 0 ifTrue:[
-		(levels at:index) safeRemove:el.
-
-		c := chain copy.
-		c addFirst:el "(self refNameFor:el in:start)".
-		chains add:c.
-	    ]
+        (start referencesObject:el) ifTrue:[
+            chain := self
+                        refChainFrom:el
+                        to:anObject
+                        inRefSets:levels
+                        startingAt:(index+1).
+
+            chain size ~~ 0 ifTrue:[
+                (levels at:index) safeRemove:el.
+
+                c := chain copy.
+                c addFirst:el "(self refNameFor:el in:start)".
+                chains add:c.
+            ]
 ].
-	].
+        ].
      ].
      ^ chains
 
-    "Created: / 2.2.1998 / 19:09:22 / cg"
-    "Modified: / 3.2.1998 / 02:38:17 / cg"
+    "Created: / 02-02-1998 / 19:09:22 / cg"
+    "Modified: / 03-02-1998 / 02:38:17 / cg"
+    "Modified: / 01-03-2019 / 16:04:15 / Claus Gittinger"
 !
 
 refNameFor:anObject in:referent