Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 8c74982

Browse files
facchinmcmaglie
authored andcommittedOct 30, 2017
Only rescan libraries folders when really needed
Scanning libraries is an heavy task if the sketchbook becomes huge; This patch targets two points: - remove the rescan() after setLibrariesFolders(), which already performs a rescan - call setLibrariesFolders() only when the folder list has changed - This ensures that no scan is performed when changing board in the same architecture Could mitigate #6350
1 parent fe35fe7 commit 8c74982

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed
 

‎arduino-core/src/cc/arduino/contributions/libraries/LibrariesIndexer.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public class LibrariesIndexer {
6060
private LibrariesIndex index;
6161
private final LibraryList installedLibraries = new LibraryList();
6262
private final LibraryList installedLibrariesWithDuplicates = new LibraryList();
63-
private List<File> librariesFolders;
63+
private ArrayList<File> librariesFolders;
6464
private final File indexFile;
6565
private final File stagingFolder;
6666
private File sketchbookLibrariesFolder;
@@ -101,11 +101,15 @@ private void parseIndex(File file) throws IOException {
101101
}
102102
}
103103

104-
public void setLibrariesFolders(List<File> _librariesFolders) {
104+
public void setLibrariesFolders(ArrayList<File> _librariesFolders) {
105105
librariesFolders = _librariesFolders;
106106
rescanLibraries();
107107
}
108108

109+
public ArrayList<File> getLibrariesFolders() {
110+
return librariesFolders;
111+
}
112+
109113
public void rescanLibraries() {
110114
// Clear all installed flags
111115
installedLibraries.clear();

‎arduino-core/src/processing/app/BaseNoGui.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public class BaseNoGui {
8787
public static Map<String, LibraryList> importToLibraryTable;
8888

8989
// XXX: Remove this field
90-
static private List<File> librariesFolders;
90+
static private ArrayList<File> librariesFolders;
9191

9292
static UserNotifier notifier = new BasicUserNotifier();
9393

@@ -679,8 +679,9 @@ static public void onBoardOrPortChange() {
679679
// Libraries located in the latest folders on the list can override
680680
// other libraries with the same name.
681681
librariesIndexer.setSketchbookLibrariesFolder(getSketchbookLibrariesFolder());
682-
librariesIndexer.setLibrariesFolders(librariesFolders);
683-
librariesIndexer.rescanLibraries();
682+
if (librariesIndexer.getLibrariesFolders() == null || !librariesIndexer.getLibrariesFolders().equals(librariesFolders)) {
683+
librariesIndexer.setLibrariesFolders(librariesFolders);
684+
}
684685

685686
populateImportToLibraryTable();
686687
}

0 commit comments

Comments
 (0)
Please sign in to comment.