From a7e02b1967a31c91ec9eb67267fe43f896a92e5f Mon Sep 17 00:00:00 2001 From: "taylor.smock" Date: Wed, 18 Dec 2024 22:36:23 +0000 Subject: [PATCH] Fix a performance issue when working with large datasets 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 --- src/org/openstreetmap/josm/gui/layer/OsmDataLayer.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/org/openstreetmap/josm/gui/layer/OsmDataLayer.java b/src/org/openstreetmap/josm/gui/layer/OsmDataLayer.java index ea39eba063..92d16c1ed1 100644 --- a/src/org/openstreetmap/josm/gui/layer/OsmDataLayer.java +++ b/src/org/openstreetmap/josm/gui/layer/OsmDataLayer.java @@ -1249,7 +1249,13 @@ public void selectionChanged(SelectionChangeEvent event) { } private void resetTiles(Collection 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; }