Changeset 18482 in josm for trunk/src/org
- Timestamp:
- 2022-06-09T15:00:28+02:00 (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/vector/VectorDataSet.java
r18193 r18482 165 165 @Override 166 166 public void clear() { 167 synchronized (this.dataStoreMap) { 168 this.dataStoreMap.clear(); 169 } 167 this.dataStoreMap.clear(); 170 168 } 171 169 … … 533 531 nearestZoom[0] = zoom; 534 532 // Create a new list to avoid concurrent modification issues 535 synchronized (this.dataStoreMap) { 536 final int[] keys = new ArrayList<>(this.dataStoreMap.keySet()).stream().filter(Objects::nonNull) 537 .mapToInt(Integer::intValue).sorted().toArray(); 538 final int index; 539 if (this.dataStoreMap.containsKey(zoom)) { 540 index = Arrays.binarySearch(keys, zoom); 541 } else { 542 // (-(insertion point) - 1) = return -> insertion point = -(return + 1) 543 index = -(Arrays.binarySearch(keys, zoom) + 1); 544 } 545 if (index > 0) { 546 nearestZoom[1] = keys[index - 1]; 547 } 548 if (index < keys.length - 2) { 549 nearestZoom[2] = keys[index + 1]; 550 } 551 552 // TODO cleanup zooms for memory 553 } 533 final int[] keys = new ArrayList<>(this.dataStoreMap.keySet()).stream().filter(Objects::nonNull) 534 .mapToInt(Integer::intValue).sorted().toArray(); 535 final int index; 536 if (this.dataStoreMap.containsKey(zoom)) { 537 index = Arrays.binarySearch(keys, zoom); 538 } else { 539 // (-(insertion point) - 1) = return -> insertion point = -(return + 1) 540 index = -(Arrays.binarySearch(keys, zoom) + 1); 541 } 542 if (index > 0) { 543 nearestZoom[1] = keys[index - 1]; 544 } 545 if (index < keys.length - 2) { 546 nearestZoom[2] = keys[index + 1]; 547 } 548 549 // TODO cleanup zooms for memory 554 550 } 555 551
Note:
See TracChangeset
for help on using the changeset viewer.