diff --git a/Source/Components/WelcomePanel.h b/Source/Components/WelcomePanel.h index f86e18a02..4a4fb91d3 100644 --- a/Source/Components/WelcomePanel.h +++ b/Source/Components/WelcomePanel.h @@ -804,7 +804,15 @@ class WelcomePanel : public Component } if (thumbImage.isNull()) { if (patchFile.existsAsFile()) { - silhoutteSvg = OfflineObjectRenderer::patchToSVG(patchFile.loadFileAsString()); + auto cachedSilhouette = patchSvgCache.find(patchFile.getFullPathName()); + if(cachedSilhouette != patchSvgCache.end()) + { + silhoutteSvg = cachedSilhouette->second; + } + else { + silhoutteSvg = OfflineObjectRenderer::patchToSVG(patchFile.loadFileAsString()); + patchSvgCache[patchFile.getFullPathName()] = silhoutteSvg; + } } } @@ -949,6 +957,7 @@ class WelcomePanel : public Component String searchQuery; Tab currentTab = Home; + UnorderedMap patchSvgCache; // To make the library panel update automatically class LibraryFSListener : public FileSystemWatcher::Listener diff --git a/Source/Pd/Library.cpp b/Source/Pd/Library.cpp index 693fd7b86..d26ada38a 100644 --- a/Source/Pd/Library.cpp +++ b/Source/Pd/Library.cpp @@ -345,11 +345,8 @@ File Library::findFile(String const& fileToFind) auto pathTree = SettingsFile::getInstance()->getValueTree().getChildWithName("Paths"); for (auto path : pathTree) { auto searchPath = File(path.getProperty("Path").toString()); - if (!searchPath.exists() || !searchPath.isDirectory()) - continue; - auto childFile = searchPath.getChildFile(fileToFind); - if (childFile.existsAsFile()) + if (OSUtils::isFileFast(childFile.getFullPathName())) return childFile; } diff --git a/Source/Utility/OSUtils.cpp b/Source/Utility/OSUtils.cpp index ba2c6bd1b..dde841405 100644 --- a/Source/Utility/OSUtils.cpp +++ b/Source/Utility/OSUtils.cpp @@ -307,6 +307,11 @@ bool OSUtils::isDirectoryFast(juce::String const& path) return fs::is_directory(path.toStdString()); } +bool OSUtils::isFileFast(juce::String const& path) +{ + return fs::is_regular_file(path.toStdString()); +} + hash32 OSUtils::getUniqueFileHash(juce::String const& path) { return hash(fs::canonical(path.toStdString()).c_str()); diff --git a/Source/Utility/OSUtils.h b/Source/Utility/OSUtils.h index b67286ead..8c047eae1 100644 --- a/Source/Utility/OSUtils.h +++ b/Source/Utility/OSUtils.h @@ -40,6 +40,7 @@ struct OSUtils { static SmallArray iterateDirectory(juce::File const& directory, bool recursive, bool onlyFiles, int maximum = -1); static bool isDirectoryFast(juce::String const& path); + static bool isFileFast(juce::String const& path); static hash32 getUniqueFileHash(juce::String const& path); static KeyboardLayout getKeyboardLayout();