Changeset 11915 in josm for trunk/src/org
- Timestamp:
- 2017-04-15T02:27:51+02:00 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/tools/ImageWarp.java
r11897 r11915 10 10 import java.util.Map; 11 11 import java.util.Set; 12 13 import org.openstreetmap.josm.Main; 12 14 13 15 /** … … 44 46 private final Map<Integer, Map<Integer, Point2D>> cache; 45 47 46 private static final boolean CONSISTENCY_TEST = false;48 private final boolean consistencyTest; 47 49 private final Set<Integer> deletedRows; 48 50 … … 56 58 this.stride = stride; 57 59 this.cache = new HashMap<>(); 58 if (CONSISTENCY_TEST) { 60 this.consistencyTest = Main.isDebugEnabled(); 61 if (consistencyTest) { 59 62 deletedRows = new HashSet<>(); 60 63 } else { … … 91 94 92 95 private Map<Integer, Point2D> getRow(int yIdx) { 93 cleanUp(yIdx - 2);96 cleanUp(yIdx - 3); 94 97 Map<Integer, Point2D> row = cache.get(yIdx); 95 98 if (row == null) { 96 99 row = new HashMap<>(); 97 100 cache.put(yIdx, row); 98 if ( CONSISTENCY_TEST) {101 if (consistencyTest) { 99 102 // should not create a row that has been deleted before 100 103 if (deletedRows.contains(yIdx)) throw new AssertionError(); 101 // only ever cache 2rows at once102 if (cache.size() > 2) throw new AssertionError();104 // only ever cache 3 rows at once 105 if (cache.size() > 3) throw new AssertionError(); 103 106 } 104 107 } … … 109 112 private void cleanUp(int yIdx) { 110 113 Map<Integer, Point2D> del = cache.remove(yIdx); 111 if ( CONSISTENCY_TEST&& del != null) {114 if (consistencyTest && del != null) { 112 115 // should delete each row only once 113 116 if (deletedRows.contains(yIdx)) throw new AssertionError();
Note:
See TracChangeset
for help on using the changeset viewer.