Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions src/main/java/com/mapconductor/core/circle/CircleController.kt
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,15 @@ abstract class CircleController<ActualCircle>(
val tiled = tiler?.route(data) ?: emptySet()
val sharedTiles = circleManager.setTiledSource(tiler)
tiledIds = tiled
val native = if (tiled.isEmpty()) data else data.filter { it.id !in tiled }
// Off the map's thread: over 723,800 tiled circles this and the
// forgetting below held it for 0.6 s per filter on a Pixel 5a.
val native =
when {
tiled.isEmpty() -> data
// Every circle is tiled (an id is tiled once, so the sizes match only then).
tiled.size == data.size -> emptyList()
else -> withContext(Dispatchers.Default) { data.filter { it.id !in tiled } }
}
val modifiedEntities = mutableListOf<CircleEntityInterface<ActualCircle>>()
// Only natively drawn circles are diffed against the renderer.
val previous =
Expand Down Expand Up @@ -138,9 +146,11 @@ abstract class CircleController<ActualCircle>(
// the tiles and the list are forgotten; those that left the tiles
// for native drawing were added above.
if (wasTiled.isNotEmpty()) {
val nativeIds = native.mapTo(HashSet()) { it.id }
for (id in wasTiled) {
if (id !in tiled && id !in nativeIds) circleManager.removeEntity(id)
withContext(Dispatchers.Default) {
val nativeIds = native.mapTo(HashSet()) { it.id }
for (id in wasTiled) {
if (id !in tiled && id !in nativeIds) circleManager.removeEntity(id)
}
}
}
if (tiled.isNotEmpty() && !sharedTiles) {
Expand Down
Loading