Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/jls/edit/Editor.java
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,8 @@ public String getDescription() {
Editor otherEditor = (Editor)edit;
if (otherEditor.getCircuit().isImported())
continue;
if (edit == this)
continue;
Comment on lines +163 to +164
Copy link
Author

@AmityWilder AmityWilder Feb 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I put the edit == this check as close to last as reasonable, since it would only be true for one editor. If it was the first check, then every editor would have to execute this test despite only one of them possibly getting skipped because of it.

Having it later means that the broader checks will have already filtered out a majority of the editors. Thus, this narrow (albeit cheap) check will only be applied to a number of editors much closer to the number of editors it could yield true for (1).

The reason it isn't after the name.equals(...) check despite that one being even broader is because, assuming Java treats ... == this the way C++ does, edit == this would be a hardware-supported 8 byte pointer equality test; much cheaper than a software-supported arbitrary-length-string equality test.

if (name.equals(otherEditor.getCircuit().getName())) {
JOptionPane.showMessageDialog(JLSInfo.frame,
"Circuit with this name already being edited");
Expand Down