From 8d21bb377ea60bad6a449d8bc438fd31b2bf9606 Mon Sep 17 00:00:00 2001 From: Amy Wilder Date: Mon, 8 Jun 2026 14:17:25 -0400 Subject: [PATCH 1/3] Implement minimal performance improvement --- src/jls/edit/SimpleEditor.java | 96 +++++++++++++++++++--------------- 1 file changed, 53 insertions(+), 43 deletions(-) diff --git a/src/jls/edit/SimpleEditor.java b/src/jls/edit/SimpleEditor.java index d588375..11dd1de 100755 --- a/src/jls/edit/SimpleEditor.java +++ b/src/jls/edit/SimpleEditor.java @@ -2837,11 +2837,15 @@ private boolean overlap() { } }*/ + untouchAll(); // may have moved and stopped touching // check every element in the selected set for (Element sel : selected) { - // check against every element in the circuit + // only one element and selected element need to be intersecting to cause a problem + boolean anyIntersection = false; + + // check against every unselected element in the circuit for (Element el : circuit.getElements()) { // ignore elements in the selected set @@ -2850,6 +2854,7 @@ private boolean overlap() { // check simple overlap of areas if (sel.intersects(el)) { + anyIntersection = true; // no overlap if possible connection, boolean ok = false; @@ -2925,16 +2930,14 @@ else if (el instanceof Wire) { } // selected is not a wire end - else { + // if not a wire end, ignore + else if (el instanceof WireEnd) { + + WireEnd end = (WireEnd)el; // put to wire end for (Put put : sel.getAllPuts()) { - // if not a wire end, ignore - if (!(el instanceof WireEnd)) - continue; - WireEnd end = (WireEnd)el; - // if don't line up, ignore if (put.getX() != end.getX() || put.getY() != end.getY()) { continue; @@ -2971,52 +2974,59 @@ else if (el instanceof Wire) { return true; } } + } - // no intersection, but wires may be overlapping wire ends - // or puts might line up - else { + // no intersection, but wires may be overlapping wire ends + // or puts might line up + if (!anyIntersection) { - // see if wires connected to a wire end dragged onto wire ends - if (sel instanceof WireEnd) { - WireEnd end = (WireEnd)sel; - for (Wire wire : end.getWires()) { - for (Element elm : circuit.getElements()) { - if (sel == elm) - continue; - if (!(elm instanceof WireEnd)) { - continue; - } - WireEnd otherEnd = (WireEnd)elm; - if (wire.touches(otherEnd)) { - overlapMessage = "overlap"; - untouchAll(); - return true; - } + // see if wires connected to a wire end dragged onto wire ends + if (sel instanceof WireEnd) { + WireEnd end = (WireEnd)sel; + for (Wire wire : end.getWires()) { + for (Element el : circuit.getElements()) { + if (sel == el) + continue; + if (!(el instanceof WireEnd)) { + continue; + } + WireEnd otherEnd = (WireEnd)el; + if (wire.touches(otherEnd)) { + overlapMessage = "overlap"; + untouchAll(); + return true; } } } + } - // see if wires connected to puts dragged onto wire ends - for (Put p : sel.getAllPuts()) { - if (p.isAttached()) { - Wire wire = p.getWireEnd().getOnlyWire(); - for (Element elm : circuit.getElements()) { - if (sel == elm) - continue; - if (!(elm instanceof WireEnd)) { - continue; - } - WireEnd otherEnd = (WireEnd)elm; - if (wire.touches(otherEnd)) { - overlapMessage = "overlap"; - untouchAll(); - return true; - } + // see if wires connected to puts dragged onto wire ends + for (Put p : sel.getAllPuts()) { + if (p.isAttached()) { + Wire wire = p.getWireEnd().getOnlyWire(); + for (Element el : circuit.getElements()) { + if (sel == el) + continue; + if (!(el instanceof WireEnd)) { + continue; + } + WireEnd otherEnd = (WireEnd)el; + if (wire.touches(otherEnd)) { + overlapMessage = "overlap"; + untouchAll(); + return true; } } } + } + + // check all put combinations + for (Element el : circuit.getElements()) { + + // ignore elements in the selected set + if (selected.contains(el)) + continue; - // check all put combinations for (Put p1 : sel.getAllPuts()) { for (Put p2 : el.getAllPuts()) { From fa389c6965d54b99ff313f6fcf9bf7af0540be02 Mon Sep 17 00:00:00 2001 From: Amy Wilder Date: Mon, 8 Jun 2026 14:25:31 -0400 Subject: [PATCH 2/3] Fix comment mistake from before refactor --- src/jls/edit/SimpleEditor.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/jls/edit/SimpleEditor.java b/src/jls/edit/SimpleEditor.java index 11dd1de..93ad4e1 100755 --- a/src/jls/edit/SimpleEditor.java +++ b/src/jls/edit/SimpleEditor.java @@ -2845,7 +2845,7 @@ private boolean overlap() { // only one element and selected element need to be intersecting to cause a problem boolean anyIntersection = false; - // check against every unselected element in the circuit + // check against every element in the circuit for (Element el : circuit.getElements()) { // ignore elements in the selected set From ec5688c42baee08dd70c94bfde70dbfb60126ea5 Mon Sep 17 00:00:00 2001 From: Amy Wilder Date: Mon, 8 Jun 2026 14:46:45 -0400 Subject: [PATCH 3/3] Clarify `anyIntersection` comment --- src/jls/edit/SimpleEditor.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/jls/edit/SimpleEditor.java b/src/jls/edit/SimpleEditor.java index 93ad4e1..bbd7525 100755 --- a/src/jls/edit/SimpleEditor.java +++ b/src/jls/edit/SimpleEditor.java @@ -2842,7 +2842,7 @@ private boolean overlap() { // check every element in the selected set for (Element sel : selected) { - // only one element and selected element need to be intersecting to cause a problem + // only one element needs to be intersecting the selected element to count as overlap boolean anyIntersection = false; // check against every element in the circuit