Skip to content

Commit 92fcb97

Browse files
Merge SketchData.sortCodes() into addCode()
By now, all calls to `addCode()` were followed by a call to `sortCodes()`, and it seems like a task for SketchData to keep its list sorted. Previously, this separation made some sense, since `addCode()` was also used while loading a sketch, and you would only want to sort once. Now, sketch loading uses a SortedSet, so this is no longer a requirement.
1 parent 24429d1 commit 92fcb97

File tree

2 files changed

+1
-8
lines changed

2 files changed

+1
-8
lines changed

app/src/processing/app/Sketch.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -375,9 +375,6 @@ protected void nameCode(String newName) {
375375
data.addCode(code);
376376
}
377377

378-
// sort the entries
379-
data.sortCode();
380-
381378
// set the new guy as current
382379
editor.selectTab(editor.findTabIndex(newName));
383380

@@ -829,7 +826,6 @@ public boolean addFile(File sourceFile) {
829826
} else {
830827
ensureExistence();
831828
data.addCode(newCode);
832-
data.sortCode();
833829
}
834830
editor.selectTab(editor.findTabIndex(filename));
835831
}

arduino-core/src/processing/app/SketchData.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ public String getMainFilePath() {
181181

182182
public void addCode(SketchCode sketchCode) {
183183
codes.add(sketchCode);
184+
Collections.sort(codes, CODE_DOCS_COMPARATOR);
184185
}
185186

186187
protected void replaceCode(SketchCode newCode) {
@@ -192,10 +193,6 @@ protected void replaceCode(SketchCode newCode) {
192193
}
193194
}
194195

195-
protected void sortCode() {
196-
Collections.sort(codes, CODE_DOCS_COMPARATOR);
197-
}
198-
199196
public SketchCode getCode(int i) {
200197
return codes.get(i);
201198
}

0 commit comments

Comments
 (0)