Ignore:
Timestamp:
2023-08-09T15:30:01+02:00 (3 years ago)
Author:
taylor.smock
Message:

Fix #22832: Code cleanup and some simplification, documentation fixes (patch by gaben)

There should not be any functional changes in this patch; it is intended to do
the following:

  • Simplify and cleanup code (example: Arrays.asList(item) -> Collections.singletonList(item))
  • Fix typos in documentation (which also corrects the documentation to match what actually happens, in some cases)
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/validation/tests/RelationChecker.java

    r18506 r18801  
    1010import java.util.EnumSet;
    1111import java.util.HashMap;
     12import java.util.HashSet;
    1213import java.util.Iterator;
    1314import java.util.LinkedHashMap;
     
    1617import java.util.List;
    1718import java.util.Map;
     19import java.util.Set;
    1820import java.util.stream.Collectors;
    1921
     
    430432
    431433    private void checkLoop(Relation parent, List<Relation> path) {
    432         if (path.contains(parent)) {
     434        Set<Relation> pathSet = new HashSet<>(path);
     435        if (pathSet.contains(parent)) {
    433436            Iterator<List<Relation>> iter = loops.iterator();
     437            Set<Relation> loop = new HashSet<>();
    434438            while (iter.hasNext()) {
    435                 List<Relation> loop = iter.next();
     439                loop.addAll(iter.next());
    436440                if (loop.size() > path.size() && loop.containsAll(path)) {
    437441                    // remove same loop with irrelevant parent
    438442                    iter.remove();
    439                 } else if (path.size() >= loop.size() && path.containsAll(loop)) {
     443                } else if (path.size() >= loop.size() && pathSet.containsAll(loop)) {
    440444                    // same or smaller loop is already known
    441445                    return;
    442446                }
     447                loop.clear();
    443448            }
    444449            if (path.get(0).equals(parent)) {
Note: See TracChangeset for help on using the changeset viewer.