Ignore:
Timestamp:
2014-09-05T14:45:30+02:00 (10 years ago)
Author:
Don-vip
Message:

fix #10483 - drastic improvement of data consistency test performance

File:
1 edited

Legend:

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

    r7500 r7501  
    99
    1010import org.openstreetmap.josm.Main;
    11 import org.openstreetmap.josm.data.coor.LatLon;
    1211import org.openstreetmap.josm.tools.Utils;
    1312
     
    105104    public void searchNodes() {
    106105        long startTime = System.currentTimeMillis();
    107         for (Node n : dataSet.getNodes()) {
    108             if (!n.isIncomplete() && !n.isDeleted()) {
    109                 LatLon c = n.getCoor();
    110                 if (c != null) {
    111                     BBox box = c.toBBox(0.0001);
    112                     if (!dataSet.searchNodes(box).contains(n)) {
    113                         printError("SEARCH NODES", "%s not found using Dataset.searchNodes()", n);
    114                     }
    115                 }
    116             }
     106        dataSet.getReadLock().lock();
     107        try {
     108            for (Node n : dataSet.getNodes()) {
     109                // Call isDrawable() as an efficient replacement to previous checks (!deleted, !incomplete, getCoor() != null)
     110                if (n.isDrawable() && !dataSet.containsNode(n)) {
     111                    printError("SEARCH NODES", "%s not found using Dataset.searchNodes()", n);
     112                }
     113            }
     114        } finally {
     115            dataSet.getReadLock().unlock();
    117116        }
    118117        printElapsedTime(startTime);
     
    124123    public void searchWays() {
    125124        long startTime = System.currentTimeMillis();
    126         for (Way w : dataSet.getWays()) {
    127             if (!w.isIncomplete() && !w.isDeleted() && w.getNodesCount() >= 2 && !dataSet.searchWays(w.getBBox()).contains(w)) {
    128                 printError("SEARCH WAYS", "%s not found using Dataset.searchWays()", w);
    129             }
     125        dataSet.getReadLock().lock();
     126        try {
     127            for (Way w : dataSet.getWays()) {
     128                if (!w.isIncomplete() && !w.isDeleted() && w.getNodesCount() >= 2 && !dataSet.containsWay(w)) {
     129                    printError("SEARCH WAYS", "%s not found using Dataset.searchWays()", w);
     130                }
     131            }
     132        } finally {
     133            dataSet.getReadLock().unlock();
    130134        }
    131135        printElapsedTime(startTime);
Note: See TracChangeset for help on using the changeset viewer.