From 73f40ac32ea71c2bc9e854e867d21bdce5cda8c8 Mon Sep 17 00:00:00 2001 From: Martino Facchin Date: Fri, 23 Jun 2017 16:50:10 +0200 Subject: [PATCH] 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 --- .../cc/arduino/contributions/libraries/LibrariesIndexer.java | 4 ++++ arduino-core/src/processing/app/BaseNoGui.java | 5 +++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/arduino-core/src/cc/arduino/contributions/libraries/LibrariesIndexer.java b/arduino-core/src/cc/arduino/contributions/libraries/LibrariesIndexer.java index a09eb2a46..5adcbf201 100644 --- a/arduino-core/src/cc/arduino/contributions/libraries/LibrariesIndexer.java +++ b/arduino-core/src/cc/arduino/contributions/libraries/LibrariesIndexer.java @@ -106,6 +106,10 @@ public class LibrariesIndexer { rescanLibraries(); } + public List getLibrariesFolders() { + return librariesFolders; + } + public void rescanLibraries() { // Clear all installed flags installedLibraries.clear(); diff --git a/arduino-core/src/processing/app/BaseNoGui.java b/arduino-core/src/processing/app/BaseNoGui.java index 62cfd0d68..e08207b0e 100644 --- a/arduino-core/src/processing/app/BaseNoGui.java +++ b/arduino-core/src/processing/app/BaseNoGui.java @@ -679,8 +679,9 @@ public class BaseNoGui { // Libraries located in the latest folders on the list can override // other libraries with the same name. librariesIndexer.setSketchbookLibrariesFolder(getSketchbookLibrariesFolder()); - librariesIndexer.setLibrariesFolders(librariesFolders); - librariesIndexer.rescanLibraries(); + if (librariesIndexer.getLibrariesFolders() == null || !librariesIndexer.getLibrariesFolders().equals(librariesFolders)) { + librariesIndexer.setLibrariesFolders(librariesFolders); + } populateImportToLibraryTable(); }