Comment 4 for bug 1556588

Revision history for this message
hilaire (hilaire-fernandes) wrote :

Pharo suffers from bad hash value for Float generating unexpected collisions on numbers as 0.5 and -0.5.
As a result Point item in DrGeo are too often seen as duplicated but there are not.

The proper way to fix this issue: in the Dr. Geo's Factory when there is hash equality between two geometric items, it should then check for the logical (ontological) equality of these two items

Code to implement it:

DrGFactory>>indexOf: anItem in: aPool
"No identity equality but hashed value to detect duplicated object we must consider as equal"
 ^ anItem
  ifNil: [0]
  ifNotNil: [aPool findFirst: [ :each |
    each hash = anItem hash
     and: ["double check when hash is equal (can be a collision)"
       each = anItem ]
   ]
  ]