Ignore:
Timestamp:
2020-02-21T11:35:40+01:00 (5 years ago)
Author:
gerdp
Message:

improve performance of Adjacent Ways action (regression from o35177)
Way.isUsable() is complex as it involves a loop over all nodes in hasIncompleteNodes()
First collect parent ways, then check each way only once.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/selection/NodeWayUtils.java

    r35177 r35334  
    88import java.util.HashSet;
    99import java.util.Iterator;
     10import java.util.LinkedHashSet;
    1011import java.util.List;
    1112import java.util.Objects;
     
    9596        List<Node> nodes = w.getNodes();
    9697        boolean flag = ways.contains(w);
    97         for (Node n: nodes) {
    98             filteredAddAll(ways, n.getParentWays());
    99         }
     98        Set<Way> parents = new LinkedHashSet<>();
     99        nodes.forEach(n -> parents.addAll(n.getParentWays()));
     100        filteredAddAll(ways, parents);
    100101        if (!flag) ways.remove(w);
    101102        return ways.size() - s;
Note: See TracChangeset for help on using the changeset viewer.