From 31284feb9be12abc5fa60fcd0da1feacf6047794 Mon Sep 17 00:00:00 2001 From: Matthijs Kooijman Date: Fri, 11 Dec 2015 19:14:09 +0100 Subject: [PATCH] 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. --- app/src/processing/app/Sketch.java | 4 ---- arduino-core/src/processing/app/SketchData.java | 5 +---- 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/app/src/processing/app/Sketch.java b/app/src/processing/app/Sketch.java index d03133844..2c2a80c53 100644 --- a/app/src/processing/app/Sketch.java +++ b/app/src/processing/app/Sketch.java @@ -374,9 +374,6 @@ public class Sketch { data.addCode(code); } - // sort the entries - data.sortCode(); - // set the new guy as current editor.selectTab(editor.findTabIndex(newName)); @@ -828,7 +825,6 @@ public class Sketch { } else { ensureExistence(); data.addCode(newCode); - data.sortCode(); } editor.selectTab(editor.findTabIndex(filename)); } diff --git a/arduino-core/src/processing/app/SketchData.java b/arduino-core/src/processing/app/SketchData.java index 02309707e..61a41d72a 100644 --- a/arduino-core/src/processing/app/SketchData.java +++ b/arduino-core/src/processing/app/SketchData.java @@ -181,6 +181,7 @@ public class SketchData { public void addCode(SketchCode sketchCode) { codes.add(sketchCode); + Collections.sort(codes, CODE_DOCS_COMPARATOR); } protected void replaceCode(SketchCode newCode) { @@ -192,10 +193,6 @@ public class SketchData { } } - protected void sortCode() { - Collections.sort(codes, CODE_DOCS_COMPARATOR); - } - public SketchCode getCode(int i) { return codes.get(i); }