﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc
24188	[WIP patch] Speed up tagging preset filtering	gaben	team	"==== What steps will reproduce the problem?
1. Open a large dataset (I'v used bus stops in Hungary, from Overpass)
2. Select all objects (Ctrl+A)
3. Open up the preset search menu (F3)
4. Start typing something, `description` for example

==== What is the expected result?
JOSM is somewhat responsive, even knowing the huge data in memory.

==== What happens instead?
JOSM is barely reaches responsive definition, around 1 char/s input speed.

==== Please provide any additional information below. Attach a screenshot if possible.
The fix makes it 2.5 times faster in my use case and the responsiveness is there.

What is happening is that JOSM is going through all presets with role definitions and then trying to regex match the selected object. Yes, all of them, one by one. Matching takes a lot of time, so prefiltering helps, but I need to make sure nothing broke, therefore marked as WIP.

{{{#!patch
Index: src/org/openstreetmap/josm/gui/tagging/presets/TaggingPresetSelector.java
===================================================================
--- src/org/openstreetmap/josm/gui/tagging/presets/TaggingPresetSelector.java	(revision 19342)
+++ src/org/openstreetmap/josm/gui/tagging/presets/TaggingPresetSelector.java	(working copy)
@@ -369,7 +369,8 @@
                     if (!suitable && preset.types.contains(TaggingPresetType.RELATION)
                             && preset.roles != null && !preset.roles.roles.isEmpty()) {
                         suitable = preset.roles.roles.stream().anyMatch(
-                                object -> object.memberExpression != null && selectedPrimitives.stream().anyMatch(object.memberExpression));
+                                role -> role.memberExpression != null
+                                        && selectedPrimitives.stream().filter(preset::typeMatches).anyMatch(role.memberExpression));
                         // keep the preset to allow the creation of new relations
                     }
                     if (!suitable) {

}}}


{{{
Revision:19342
Is-Local-Build:true
Build-Date:2025-03-02 12:46:28

Identification: JOSM/1.5 (19342 SVN en) Linux Ubuntu 22.04.5 LTS
Memory Usage: 314 MB / 3988 MB (207 MB allocated, but free)
Java version: 21.0.6+7-Ubuntu-122.04.1, Ubuntu, OpenJDK 64-Bit Server VM
}}}
"	enhancement	new	normal		Core			template_report performance preset	
