Changeset 8850 in josm for trunk/src/org


Ignore:
Timestamp:
2015-10-10T15:15:14+02:00 (9 years ago)
Author:
Don-vip
Message:

sonar - squid:S3047 - Multiple loops over the same set should be combined

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

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/actions/OrthogonalizeAction.java

    r8836 r8850  
    255255                wayDataList.get(0).calcDirections(Direction.RIGHT);
    256256                double refHeading = wayDataList.get(0).heading;
     257                EastNorth totSum = new EastNorth(0., 0.);
    257258                for (WayData w : wayDataList) {
    258259                    w.calcDirections(Direction.RIGHT);
    259260                    int directionOffset = angleToDirectionChange(w.heading - refHeading, TOLERANCE2);
    260261                    w.calcDirections(Direction.RIGHT.changeBy(directionOffset));
    261                     if (angleToDirectionChange(refHeading - w.heading, TOLERANCE2) != 0) throw new RuntimeException();
    262                 }
    263                 EastNorth totSum = new EastNorth(0., 0.);
    264                 for (WayData w : wayDataList) {
     262                    if (angleToDirectionChange(refHeading - w.heading, TOLERANCE2) != 0)
     263                        throw new RuntimeException();
    265264                    totSum = EN.sum(totSum, w.segSum);
    266265                }
     
    343342                    }
    344343                }
     344
     345                final Map<Node, Double> nC = (orientation == HORIZONTAL) ? nY : nX;
     346
     347                double average = 0;
    345348                for (Node n : cs) {
    346349                    s.remove(n);
    347                 }
    348 
    349                 final Map<Node, Double> nC = (orientation == HORIZONTAL) ? nY : nX;
    350 
    351                 double average = 0;
    352                 for (Node n : cs) {
    353350                    average += nC.get(n).doubleValue();
    354351                }
  • trunk/src/org/openstreetmap/josm/actions/mapmode/DrawAction.java

    r8840 r8850  
    652652            for (int i : is) {
    653653                segSet.add(Pair.sort(new Pair<>(w.getNode(i), w.getNode(i+1))));
    654             }
    655             for (int i : is) {
    656654                wnew.addNode(i + 1, n);
    657655            }
  • trunk/src/org/openstreetmap/josm/data/validation/tests/DuplicateRelation.java

    r8836 r8850  
    243243        long idToKeep = 0;
    244244        Relation relationToKeep = relFix.iterator().next();
    245         // Only one relation will be kept - the one with lowest positive ID, if such exist
    246         // or one "at random" if no such exists. Rest of the relations will be deleted
    247         for (Relation w: relFix) {
    248             if (!w.isNew() && (idToKeep == 0 || w.getId() < idToKeep)) {
    249                 idToKeep = w.getId();
    250                 relationToKeep = w;
    251             }
    252         }
    253 
    254245        // Find the relation that is member of one or more relations. (If any)
    255246        Relation relationWithRelations = null;
     
    262253                relationWithRelations = w;
    263254                relRef = rel;
     255            }
     256            // Only one relation will be kept - the one with lowest positive ID, if such exist
     257            // or one "at random" if no such exists. Rest of the relations will be deleted
     258            if (!w.isNew() && (idToKeep == 0 || w.getId() < idToKeep)) {
     259                idToKeep = w.getId();
     260                relationToKeep = w;
    264261            }
    265262        }
  • trunk/src/org/openstreetmap/josm/data/validation/tests/DuplicateWay.java

    r8836 r8850  
    253253        long idToKeep = 0;
    254254        Way wayToKeep = ways.iterator().next();
    255         // Only one way will be kept - the one with lowest positive ID, if such exist
    256         // or one "at random" if no such exists. Rest of the ways will be deleted
    257         for (Way w: ways) {
    258             if (!w.isNew() && (idToKeep == 0 || w.getId() < idToKeep)) {
    259                 idToKeep = w.getId();
    260                 wayToKeep = w;
    261             }
    262         }
    263 
    264255        // Find the way that is member of one or more relations. (If any)
    265256        Way wayWithRelations = null;
     
    273264                relations = rel;
    274265            }
     266            // Only one way will be kept - the one with lowest positive ID, if such exist
     267            // or one "at random" if no such exists. Rest of the ways will be deleted
     268            if (!w.isNew() && (idToKeep == 0 || w.getId() < idToKeep)) {
     269                idToKeep = w.getId();
     270                wayToKeep = w;
     271            }
    275272        }
    276273
  • trunk/src/org/openstreetmap/josm/gui/preferences/map/MapPaintPreference.java

    r8836 r8850  
    259259                    }
    260260                }
    261             }
    262 
    263             for (SourceEntry def : defaults) {
    264261                knownDefaults.add(def.url);
    265262            }
  • trunk/src/org/openstreetmap/josm/io/session/SessionReader.java

    r8540 r8850  
    503503                }
    504504            }
    505         }
    506         for (Entry<Integer, Layer> e : layersMap.entrySet()) {
    507             Layer l = e.getValue();
    508             if (l == null) {
    509                 continue;
    510             }
    511 
    512             l.setName(names.get(e.getKey()));
    513             layers.add(l);
     505            layer.setName(names.get(entry.getKey()));
     506            layers.add(layer);
    514507        }
    515508    }
Note: See TracChangeset for help on using the changeset viewer.