Skip to content

Commit

Permalink
Fix a performance issue when working with large datasets
Browse files Browse the repository at this point in the history
The primary issue is that the collection passed to the resetTiles method is a
filtered collection with no defined size. In order to calculate the size, it must
iterate through the collection which becomes expensive with large datasets.

The fix for this is to remove the dependency on the size of the dataset, and just
look at the number of primitives passed in.

In addition, if the current renderer is ''not'' StyledTiledMapRenderer, clear the cache and return.

git-svn-id: https://josm.openstreetmap.de/svn/trunk@19271 0c6e7542-c601-0410-84e7-c038aed88b3b
  • Loading branch information
taylor.smock committed Dec 18, 2024
1 parent 3bb871f commit a7e02b1
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/org/openstreetmap/josm/gui/layer/OsmDataLayer.java
Original file line number Diff line number Diff line change
Expand Up @@ -1249,7 +1249,13 @@ public void selectionChanged(SelectionChangeEvent event) {
}

private void resetTiles(Collection<? extends IPrimitive> primitives) {
if (primitives.size() >= this.data.allNonDeletedCompletePrimitives().size() || primitives.size() > 100) {
// Clear the cache if we aren't using tiles. And return.
if (!MapRendererFactory.getInstance().isMapRendererActive(StyledTiledMapRenderer.class)) {
this.cache.clear();
return;
}
// Don't use anything that uses filtered collections. It becomes slow at large datasets.
if (primitives.size() > 100) {
dirtyAll();
return;
}
Expand Down

0 comments on commit a7e02b1

Please sign in to comment.