Changeset 18465 in josm


Ignore:
Timestamp:
2022-06-06T16:56:25+02:00 (2 years ago)
Author:
taylor.smock
Message:

Fix #22106: Avoid allocations for point objects in QuadBuckets

Nodes do not keep their bboxes in memory (to reduce overall memory usage).
This does mean that every time someone searches a quadbucket for nodes, we
have to recreate the BBox for every node in a quadbucket leaf. This is a
significant number of allocations that are unnecessary (~80% of the memory
allocations from QuadBuckets#search for nodes is from the creation of
temporary bboxes). The remaining cost for the search is from List#grow calls.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/osm/QuadBuckets.java

    r18246 r18465  
    1212
    1313import org.openstreetmap.josm.data.IQuadBucketType;
     14import org.openstreetmap.josm.data.coor.ILatLon;
    1415import org.openstreetmap.josm.data.coor.LatLon;
    1516import org.openstreetmap.josm.data.coor.QuadTiling;
     
    174175
    175176        boolean matches(final T o, final BBox searchBbox) {
     177            // Avoid allocations for point (AKA Node) objects
     178            if (o instanceof ILatLon) {
     179                return searchBbox.contains((ILatLon) o);
     180            }
    176181            return o.getBBox().intersects(searchBbox);
    177182        }
Note: See TracChangeset for help on using the changeset viewer.