Ticket #22808: 22808.2.patch
File 22808.2.patch, 4.2 KB (added by , 20 months ago) |
---|
-
src/org/openstreetmap/josm/command/AddPrimitivesCommand.java
Subject: [PATCH] Fix #22808: Undoing "Paste" for ways of a route relation is very slow --- IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 diff --git a/src/org/openstreetmap/josm/command/AddPrimitivesCommand.java b/src/org/openstreetmap/josm/command/AddPrimitivesCommand.java
a b 17 17 import org.openstreetmap.josm.data.osm.NodeData; 18 18 import org.openstreetmap.josm.data.osm.OsmPrimitive; 19 19 import org.openstreetmap.josm.data.osm.PrimitiveData; 20 import org.openstreetmap.josm.data.osm.PrimitiveId; 20 21 import org.openstreetmap.josm.tools.CheckParameterUtil; 21 22 22 23 /** … … 127 128 createdPrimitives = PurgeCommand.topoSort(createdPrimitives); 128 129 } 129 130 // reversed order, see #14620 131 List<PrimitiveId> toRemove = new ArrayList<>(this.createdPrimitives.size()); 130 132 for (int i = createdPrimitives.size() - 1; i >= 0; i--) { 131 133 OsmPrimitive osm = createdPrimitives.get(i); 132 134 Optional<PrimitiveData> previous = preExistingData.stream() … … 134 136 if (previous.isPresent()) { 135 137 osm.load(previous.get()); 136 138 } else { 139 toRemove.add(osm); 137 140 ds.removePrimitive(osm); 138 141 } 139 142 } 143 ds.removePrimitives(toRemove); 140 144 } 141 145 142 146 @Override -
src/org/openstreetmap/josm/data/osm/DataSet.java
IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 diff --git a/src/org/openstreetmap/josm/data/osm/DataSet.java b/src/org/openstreetmap/josm/data/osm/DataSet.java
a b 5 5 6 6 import java.awt.geom.Area; 7 7 import java.util.ArrayList; 8 import java.util.Arrays; 8 9 import java.util.Collection; 9 10 import java.util.Collections; 10 11 import java.util.HashMap; … … 564 565 }); 565 566 } 566 567 568 /** 569 * Removes primitives from the dataset. This method only removes the 570 * primitives form the respective collection of primitives managed 571 * by this dataset, i.e. from {@code store.nodes}, {@code store.ways}, or 572 * {@code store.relations}. References from other primitives to this 573 * primitive are left unchanged. 574 * 575 * @param primitiveIds the ids of the primitive 576 * @throws IllegalStateException if the dataset is read-only 577 * @since xxx 578 */ 579 public void removePrimitives(PrimitiveId... primitiveIds) { 580 this.removePrimitives(Arrays.asList(primitiveIds)); 581 } 582 583 /** 584 * Removes primitives from the dataset. This method only removes the 585 * primitives form the respective collection of primitives managed 586 * by this dataset, i.e. from {@code store.nodes}, {@code store.ways}, or 587 * {@code store.relations}. References from other primitives to this 588 * primitive are left unchanged. 589 * 590 * @param primitiveIds the ids of the primitive 591 * @throws IllegalStateException if the dataset is read-only 592 * @since xxx 593 */ 594 public void removePrimitives(Collection<PrimitiveId> primitiveIds) { 595 checkModifiable(); 596 update(() -> { 597 final List<OsmPrimitive> removed = new ArrayList<>(primitiveIds.size()); 598 for (PrimitiveId primitiveId : primitiveIds) { 599 OsmPrimitive primitive = this.getPrimitiveByIdChecked(primitiveId); 600 if (primitive == null) { 601 continue; 602 } 603 removePrimitiveImpl(primitive); 604 removed.add(primitive); 605 } 606 firePrimitivesRemoved(removed, false); 607 }); 608 } 609 567 610 private void removePrimitiveImpl(OsmPrimitive primitive) { 568 611 clearSelection(primitive.getPrimitiveId()); 569 612 if (primitive.isSelected()) {