Changeset 18464 in josm for trunk/test/unit


Ignore:
Timestamp:
2022-06-06T16:04:20+02:00 (3 years ago)
Author:
taylor.smock
Message:

Extract equalsEpsilon from LatLon into ILatLon

This significantly reduces allocations from DataSetMerger#merge.
In testing, it went from ~400 MiB allocations to ~19 MiB allocations.

The allocations largely came from checking if two nodes had equal coordinates.
The code used LatLon#getCoor followed by equalsEpsilon, when all the
required information was already present in Node, but LatLon had the method.

As an additional enhancement, equalsEpsilon was somewhat generified, in that
there is an additional method where we can specify a different precision.

This fixes #22104, see #7159.

Location:
trunk/test/unit/org/openstreetmap/josm
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/unit/org/openstreetmap/josm/gui/datatransfer/OsmTransferHandlerTest.java

    r17275 r18464  
    4949
    5050        transferHandler.pasteOn(target, null);
    51         assertTrue(n1.getCoor().equalsEpsilon(ds2.getNodes().iterator().next().getCoor()));
     51        assertTrue(n1.equalsEpsilon(ds2.getNodes().iterator().next()));
    5252
    5353        ds2.clear();
     
    5656        LatLon pos = new LatLon(55, -5);
    5757        transferHandler.pasteOn(target, ProjectionRegistry.getProjection().latlon2eastNorth(pos));
    58         assertTrue(pos.equalsEpsilon(ds2.getNodes().iterator().next().getCoor()));
     58        assertTrue(pos.equalsEpsilon(ds2.getNodes().iterator().next()));
    5959    }
    6060
  • trunk/test/unit/org/openstreetmap/josm/io/GeoJSONReaderTest.java

    r18037 r18464  
    167167        return (p1 instanceof Node)
    168168            && (p2 instanceof Node)
    169             && ((Node) p1).getCoor().equalsEpsilon(((Node) p2).getCoor());
     169            && ((Node) p1).equalsEpsilon(((Node) p2));
    170170    }
    171171
Note: See TracChangeset for help on using the changeset viewer.