[Pharo-project] Issue 3341 in pharo: use #= for integer comparison instead of #==

pharo at googlecode.com pharo at googlecode.com
Sat Nov 27 17:25:29 CET 2010


Comment #2 on issue 3341 by stephane.ducasse: use #= for integer comparison  
instead of #==
http://code.google.com/p/pharo/issues/detail?id=3341

http://source.squeak.org/trunk/Kernel-ul.516.mcz

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

Name: Kernel-ul.516
Author: ul
Time: 15 November 2010, 11:23:57.645 am
UUID: 6faf4568-4121-8543-897b-a4aef9f01454
Ancestors: Kernel-ul.515

- reverted Object >> #inboundPointersExcluding: and added a comment with  
some explanation about the use of #==.

=============== Diff against Kernel-ul.515 ===============

Item was changed:
  ----- Method: Object>>inboundPointersExcluding: (in category 'tracing')  
-----
  inboundPointersExcluding: objectsToExclude
  "Answer a list of all objects in the system that point to me, excluding  
those in the collection of objectsToExclude. I do my best to avoid creating  
any temporary objects that point to myself, especially method and block  
contexts. Adapted from PointerFinder class >> #pointersTo:except:"

        | anObj pointers objectsToAlwaysExclude |
        Smalltalk garbageCollect.
        "big collection shouldn't grow, so it's contents array is always the  
same"
        pointers := OrderedCollection new: 1000.

        "#allObjectsDo: and #pointsTo: are expanded inline to keep spurious
         method and block contexts out of the results"
        anObj := self someObject.
+       [0 == anObj] whileFalse: [ "We must use #== here, to avoid leaving  
the loop when anObj is another number that's equal to 0 (e.g. 0.0)."
-       [0 = anObj] whileFalse: [
                anObj isInMemory
                        ifTrue: [((anObj instVarsInclude: self)
                                or: [anObj class == self])
                                        ifTrue: [pointers add: anObj]].
                anObj := anObj nextObject].

        objectsToAlwaysExclude := {
                pointers collector.
                thisContext.
                thisContext sender.
                thisContext sender sender.
                objectsToExclude.
        }.

        ^ pointers removeAllSuchThat: [:ea |
                (objectsToAlwaysExclude identityIncludes: ea)
                        or: [objectsToExclude identityIncludes: ea]]!






More information about the Pharo-project mailing list