Changeset 18792 in josm


Ignore:
Timestamp:
2023-08-07T17:21:45+02:00 (11 months ago)
Author:
taylor.smock
Message:

Fix #23018: The Name Suggestion Index preset causes dramatic slowing in line drawing and following

The root cause is that every time the dataset fires a DataChangedEvent, we
rebuild the relation list. This causes a search in the presets, which can become
very expensive with the NSI. To fix this, we instead iterate through each
individual event in the DataChangedEvent, and perform the appropriate action.

Location:
trunk/src/org/openstreetmap/josm
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/osm/event/DataSetListener.java

    r9239 r18792  
    6464     */
    6565    void dataChanged(DataChangedEvent event);
     66
     67    /**
     68     * Call each subevent of a {@link DataChangedEvent}. This should only ever be called from
     69     * {@link #dataChanged(DataChangedEvent)}.
     70     * @param event The event to call the individual elements from
     71     * @implNote Implementors should decide what they want to do with {@code event == null},
     72     * {@code event.getEvents() == null}, and {@code event.getEvents().isEmpty()}.
     73     * @since 18792
     74     */
     75    default void dataChangedIndividualEvents(DataChangedEvent event) {
     76        for (AbstractDatasetChangedEvent subEvent : event.getEvents()) {
     77            if (subEvent instanceof PrimitivesAddedEvent) {
     78                this.primitivesAdded((PrimitivesAddedEvent) subEvent);
     79            } else if (subEvent instanceof PrimitivesRemovedEvent) {
     80                this.primitivesRemoved((PrimitivesRemovedEvent) subEvent);
     81            } else if (subEvent instanceof TagsChangedEvent) {
     82                this.tagsChanged((TagsChangedEvent) subEvent);
     83            } else if (subEvent instanceof NodeMovedEvent) {
     84                this.nodeMoved((NodeMovedEvent) subEvent);
     85            } else if (subEvent instanceof WayNodesChangedEvent) {
     86                this.wayNodesChanged((WayNodesChangedEvent) subEvent);
     87            } else if (subEvent instanceof RelationMembersChangedEvent) {
     88                this.relationMembersChanged((RelationMembersChangedEvent) subEvent);
     89            } else {
     90                this.otherDatasetChange(subEvent);
     91            }
     92        }
     93    }
    6694}
  • trunk/src/org/openstreetmap/josm/gui/dialogs/RelationListDialog.java

    r18715 r18792  
    736736    @Override
    737737    public void dataChanged(DataChangedEvent event) {
    738         initFromData(MainApplication.getLayerManager().getActiveData());
     738        // I have no clue how it would be empty, but just in case use the original code.
     739        // {@code null} is used during initialization
     740        if (event == null || Utils.isEmpty(event.getEvents())) {
     741            initFromData(MainApplication.getLayerManager().getActiveData());
     742        } else {
     743            dataChangedIndividualEvents(event);
     744        }
    739745    }
    740746
  • trunk/src/org/openstreetmap/josm/plugins/PluginHandler.java

    r18790 r18792  
    649649
    650650    private static void alertJavaUpdateRequired(Component parent, String plugin, int requiredVersion) {
    651         final ButtonSpec[] options = new ButtonSpec[] {
     651        final ButtonSpec[] options = {
    652652                new ButtonSpec(tr("OK"), ImageProvider.get("ok"), tr("Click to close the dialog"), null),
    653653                new ButtonSpec(tr("Update Java"), ImageProvider.get("java"), tr("Update Java"), null)
Note: See TracChangeset for help on using the changeset viewer.