Skip to content

Commit 31284fe

Browse files
matthijskooijmanfacchinm
authored andcommitted
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 f7fdd08 commit 31284fe

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
@@ -374,9 +374,6 @@ protected void nameCode(String newName) {
374374
data.addCode(code);
375375
}
376376

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

@@ -828,7 +825,6 @@ public boolean addFile(File sourceFile) {
828825
} else {
829826
ensureExistence();
830827
data.addCode(newCode);
831-
data.sortCode();
832828
}
833829
editor.selectTab(editor.findTabIndex(filename));
834830
}

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)