Changeset 11292 in josm


Ignore:
Timestamp:
2016-11-22T15:42:54+01:00 (4 months ago)
Author:
simon04
Message:

see #14025 - Merge layers performance: run quick/decisive checks first

Location:
trunk/src/org/openstreetmap/josm/data/osm
Files:
4 edited

Legend:

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

    r11269 r11292  
    298298    @Override
    299299    public boolean hasEqualSemanticAttributes(OsmPrimitive other, boolean testInterestingTagsOnly) {
    300         if (!(other instanceof Node))
    301             return false;
    302         if (!super.hasEqualSemanticAttributes(other, testInterestingTagsOnly))
    303             return false;
    304         Node n = (Node) other;
    305         LatLon coor = getCoor();
    306         LatLon otherCoor = n.getCoor();
    307         if (coor == null && otherCoor == null)
    308             return true;
    309         else if (coor != null && otherCoor != null)
    310             return coor.equalsEpsilon(otherCoor);
    311         else
    312             return false;
     300        return (other instanceof Node)
     301                && hasEqualSemanticFlags(other)
     302                && hasEqualCoordinates((Node) other)
     303                && super.hasEqualSemanticAttributes(other, testInterestingTagsOnly);
     304    }
     305
     306    private boolean hasEqualCoordinates(Node other) {
     307        final LatLon c1 = getCoor();
     308        final LatLon c2 = other.getCoor();
     309        return (c1 == null && c2 == null) || (c1 != null && c2 != null && c1.equalsEpsilon(c2));
    313310    }
    314311
  • trunk/src/org/openstreetmap/josm/data/osm/OsmPrimitive.java

    r11291 r11292  
    11881188    }
    11891189
    1190     boolean hasEqualSemanticAttributes(final OsmPrimitive other, final boolean testInterestingTagsOnly) {
     1190    boolean hasEqualSemanticFlags(final OsmPrimitive other) {
    11911191        if (!isNew() && id != other.id)
    11921192            return false;
    11931193        if (isIncomplete() ^ other.isIncomplete()) // exclusive or operator for performance (see #7159)
    11941194            return false;
    1195         return testInterestingTagsOnly ? hasSameInterestingTags(other) : getKeys().equals(other.getKeys());
     1195        return true;
     1196    }
     1197
     1198    boolean hasEqualSemanticAttributes(final OsmPrimitive other, final boolean testInterestingTagsOnly) {
     1199        return hasEqualSemanticFlags(other)
     1200                && (testInterestingTagsOnly ? hasSameInterestingTags(other) : getKeys().equals(other.getKeys()));
    11961201    }
    11971202
  • trunk/src/org/openstreetmap/josm/data/osm/Relation.java

    r11269 r11292  
    303303    @Override
    304304    public boolean hasEqualSemanticAttributes(OsmPrimitive other, boolean testInterestingTagsOnly) {
    305         if (!(other instanceof Relation))
    306             return false;
    307         if (!super.hasEqualSemanticAttributes(other, testInterestingTagsOnly))
    308             return false;
    309         Relation r = (Relation) other;
    310         return Arrays.equals(members, r.members);
     305        return (other instanceof Relation)
     306                && hasEqualSemanticFlags(other)
     307                && Arrays.equals(members, ((Relation) other).members)
     308                && super.hasEqualSemanticAttributes(other, testInterestingTagsOnly);
    311309    }
    312310
  • trunk/src/org/openstreetmap/josm/data/osm/Way.java

    r11269 r11292  
    334334        if (!(other instanceof Way))
    335335            return false;
     336        Way w = (Way) other;
     337        if (getNodesCount() != w.getNodesCount()) return false;
    336338        if (!super.hasEqualSemanticAttributes(other, testInterestingTagsOnly))
    337339            return false;
    338         Way w = (Way) other;
    339         if (getNodesCount() != w.getNodesCount()) return false;
    340340        for (int i = 0; i < getNodesCount(); i++) {
    341341            if (!getNode(i).hasEqualSemanticAttributes(w.getNode(i)))
Note: See TracChangeset for help on using the changeset viewer.