Changeset 11915 in josm for trunk


Ignore:
Timestamp:
2017-04-15T02:27:51+02:00 (7 years ago)
Author:
bastiK
Message:

see #7427 - run consistency test in debug mode

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/tools/ImageWarp.java

    r11897 r11915  
    1010import java.util.Map;
    1111import java.util.Set;
     12
     13import org.openstreetmap.josm.Main;
    1214
    1315/**
     
    4446        private final Map<Integer, Map<Integer, Point2D>> cache;
    4547
    46         private static final boolean CONSISTENCY_TEST = false;
     48        private final boolean consistencyTest;
    4749        private final Set<Integer> deletedRows;
    4850
     
    5658            this.stride = stride;
    5759            this.cache = new HashMap<>();
    58             if (CONSISTENCY_TEST) {
     60            this.consistencyTest = Main.isDebugEnabled();
     61            if (consistencyTest) {
    5962                deletedRows = new HashSet<>();
    6063            } else {
     
    9194
    9295        private Map<Integer, Point2D> getRow(int yIdx) {
    93             cleanUp(yIdx - 2);
     96            cleanUp(yIdx - 3);
    9497            Map<Integer, Point2D> row = cache.get(yIdx);
    9598            if (row == null) {
    9699                row = new HashMap<>();
    97100                cache.put(yIdx, row);
    98                 if (CONSISTENCY_TEST) {
     101                if (consistencyTest) {
    99102                    // should not create a row that has been deleted before
    100103                    if (deletedRows.contains(yIdx)) throw new AssertionError();
    101                     // only ever cache 2 rows at once
    102                     if (cache.size() > 2) throw new AssertionError();
     104                    // only ever cache 3 rows at once
     105                    if (cache.size() > 3) throw new AssertionError();
    103106                }
    104107            }
     
    109112        private void cleanUp(int yIdx) {
    110113            Map<Integer, Point2D> del = cache.remove(yIdx);
    111             if (CONSISTENCY_TEST && del != null) {
     114            if (consistencyTest && del != null) {
    112115                // should delete each row only once
    113116                if (deletedRows.contains(yIdx)) throw new AssertionError();
Note: See TracChangeset for help on using the changeset viewer.