Modify ↓
Opened 23 months ago
Closed 23 months ago
#22106 closed defect (fixed)
[PATCH] Avoid allocations for point objects (Nodes) in QuadBuckets
Reported by: | taylor.smock | Owned by: | team |
---|---|---|---|
Priority: | normal | Milestone: | 22.06 |
Component: | Core | Version: | |
Keywords: | performance | Cc: |
Description
-
src/org/openstreetmap/josm/data/osm/QuadBuckets.java
diff --git a/src/org/openstreetmap/josm/data/osm/QuadBuckets.java b/src/org/openstreetmap/josm/data/osm/QuadBuckets.java index 1f126bbb0b..916a1d048c 100644
a b import java.util.NoSuchElementException; 11 11 import java.util.stream.IntStream; 12 12 13 13 import org.openstreetmap.josm.data.IQuadBucketType; 14 import org.openstreetmap.josm.data.coor.ILatLon; 14 15 import org.openstreetmap.josm.data.coor.LatLon; 15 16 import org.openstreetmap.josm.data.coor.QuadTiling; 16 17 import org.openstreetmap.josm.tools.Logging; … … public class QuadBuckets<T extends IQuadBucketType> implements Collection<T> { 173 174 } 174 175 175 176 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 } 176 181 return o.getBBox().intersects(searchBbox); 177 182 } 178 183
This reduces the allocations for Nodes in QuadBuckets.QBLevel#matches by 80% (we're no longer creating a new BBox
every time). The remaining cost is from ArrayList#grow
.
Unfortunately, this isn't a major perf win (it is dwarfed by other things) but it does shave a percentage point or two off of the render path allocations.
Attachments (0)
Change History (2)
comment:1 by , 23 months ago
Milestone: | → 22.06 |
---|
comment:2 by , 23 months ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Note:
See TracTickets
for help on using tickets.
In 18465/josm: