From 53855957642ba6cc967975f3b5022c3c2f0851e7 Mon Sep 17 00:00:00 2001 From: falkTX Date: Sat, 21 May 2022 03:23:59 +0100 Subject: [PATCH] Continue cleanup Signed-off-by: falkTX --- source/backend/engine/CarlaEngine.cpp | 10 +++++----- source/backend/plugin/CarlaPluginNative.cpp | 1 - source/backend/utils/CachedPlugins.cpp | 15 +++++++++------ source/includes/CarlaNativePrograms.hpp | 8 ++++---- source/modules/water/files/File.cpp | 18 +++++++++--------- source/modules/water/files/File.h | 4 +++- source/utils/CarlaDssiUtils.cpp | 2 +- 7 files changed, 31 insertions(+), 27 deletions(-) diff --git a/source/backend/engine/CarlaEngine.cpp b/source/backend/engine/CarlaEngine.cpp index b73b011ac..ff57e5264 100644 --- a/source/backend/engine/CarlaEngine.cpp +++ b/source/backend/engine/CarlaEngine.cpp @@ -2579,7 +2579,7 @@ static String findBinaryInCustomPath(const char* const searchPath, const char* c searchFlags |= File::findDirectories; #endif - Array results; + std::vector results; for (const String *it=searchPaths.begin(), *end=searchPaths.end(); it != end; ++it) { const File path(*it); @@ -2587,8 +2587,8 @@ static String findBinaryInCustomPath(const char* const searchPath, const char* c results.clear(); path.findChildFiles(results, searchFlags, true, filename); - if (results.size() > 0) - return results.getFirst().getFullPathName(); + if (!results.empty()) + return results.front().getFullPathName(); } // try changing extension @@ -2612,8 +2612,8 @@ static String findBinaryInCustomPath(const char* const searchPath, const char* c results.clear(); path.findChildFiles(results, searchFlags, true, filename); - if (results.size() > 0) - return results.getFirst().getFullPathName(); + if (!results.empty()) + return results.front().getFullPathName(); } return String(); diff --git a/source/backend/plugin/CarlaPluginNative.cpp b/source/backend/plugin/CarlaPluginNative.cpp index d8035cbd2..4f22cb609 100644 --- a/source/backend/plugin/CarlaPluginNative.cpp +++ b/source/backend/plugin/CarlaPluginNative.cpp @@ -25,7 +25,6 @@ #include "water/misc/Time.h" #include "water/text/StringArray.h" -using water::jmax; using water::String; using water::StringArray; diff --git a/source/backend/utils/CachedPlugins.cpp b/source/backend/utils/CachedPlugins.cpp index 39d8386cd..7d5de043c 100644 --- a/source/backend/utils/CachedPlugins.cpp +++ b/source/backend/utils/CachedPlugins.cpp @@ -72,11 +72,11 @@ _CarlaCachedPluginInfo::_CarlaCachedPluginInfo() noexcept // ------------------------------------------------------------------------------------------------------------------- -static water::Array gSFZs; +static std::vector gSFZs; static void findSFZs(const char* const sfzPaths) { - gSFZs.clearQuick(); + gSFZs.clear(); CARLA_SAFE_ASSERT_RETURN(sfzPaths != nullptr,); @@ -87,10 +87,13 @@ static void findSFZs(const char* const sfzPaths) for (water::String *it = splitPaths.begin(), *end = splitPaths.end(); it != end; ++it) { - water::Array results; + std::vector results; if (water::File(*it).findChildFiles(results, water::File::findFiles|water::File::ignoreHiddenFiles, true, "*.sfz") > 0) - gSFZs.addArray(results); + { + gSFZs.reserve(gSFZs.size() + results.size()); + gSFZs.insert(gSFZs.end(), results.begin(), results.end()); + } } } @@ -699,8 +702,8 @@ const CarlaCachedPluginInfo* carla_get_cached_plugin_info(CB::PluginType ptype, #endif case CB::PLUGIN_SFZ: { - CARLA_SAFE_ASSERT_BREAK(index < static_cast(gSFZs.size())); - return get_cached_plugin_sfz(gSFZs.getUnchecked(static_cast(index))); + CARLA_SAFE_ASSERT_BREAK(index < gSFZs.size()); + return get_cached_plugin_sfz(gSFZs[index]); } default: diff --git a/source/includes/CarlaNativePrograms.hpp b/source/includes/CarlaNativePrograms.hpp index 46239b7c8..afefc3471 100644 --- a/source/includes/CarlaNativePrograms.hpp +++ b/source/includes/CarlaNativePrograms.hpp @@ -63,12 +63,12 @@ struct NativePluginPresetManager { for (String *it = splitPaths.begin(), *end = splitPaths.end(); it != end; ++it) { - Array results; + std::vector results; - if (File(*it).findChildFiles(results, File::findFiles|File::ignoreHiddenFiles, true, wildcard) > 0) + if (const int count = File(*it).findChildFiles(results, File::findFiles|File::ignoreHiddenFiles, true, wildcard)) { - for (File *it2 = results.begin(), *end2 = results.end(); it2 != end2; ++it2) - filenames.add(it2->getFullPathName()); + for (int i=0; i subFiles; + std::vector subFiles; findChildFiles (subFiles, File::findFilesAndDirectories, false); for (int i = subFiles.size(); --i >= 0;) - worked = subFiles.getReference(i).deleteRecursively() && worked; + worked = subFiles[i].deleteRecursively() && worked; } return deleteFile() && worked; @@ -315,12 +315,12 @@ bool File::copyDirectoryTo (const File& newDirectory) const { if (isDirectory() && newDirectory.createDirectory()) { - Array subFiles; + std::vector subFiles; findChildFiles (subFiles, File::findFiles, false); - for (int i = 0; i < subFiles.size(); ++i) + for (size_t i = 0; i < subFiles.size(); ++i) { - const File& src (subFiles.getReference(i)); + const File& src (subFiles[i]); const File& dst (newDirectory.getChildFile (src.getFileName())); if (src.isSymbolicLink()) @@ -338,8 +338,8 @@ bool File::copyDirectoryTo (const File& newDirectory) const subFiles.clear(); findChildFiles (subFiles, File::findDirectories, false); - for (int i = 0; i < subFiles.size(); ++i) - if (! subFiles.getReference(i).copyDirectoryTo (newDirectory.getChildFile (subFiles.getReference(i).getFileName()))) + for (size_t i = 0; i < subFiles.size(); ++i) + if (! subFiles[i].copyDirectoryTo (newDirectory.getChildFile (subFiles[i].getFileName()))) return false; return true; @@ -556,7 +556,7 @@ void File::readLines (StringArray& destLines) const } //============================================================================== -int File::findChildFiles (Array& results, +int File::findChildFiles (std::vector& results, const int whatToLookFor, const bool searchRecursively, const String& wildCardPattern) const @@ -565,7 +565,7 @@ int File::findChildFiles (Array& results, for (DirectoryIterator di (*this, searchRecursively, wildCardPattern, whatToLookFor); di.next();) { - results.add (di.getFile()); + results.push_back (di.getFile()); ++total; } diff --git a/source/modules/water/files/File.h b/source/modules/water/files/File.h index b52389e67..f92613267 100644 --- a/source/modules/water/files/File.h +++ b/source/modules/water/files/File.h @@ -30,6 +30,8 @@ #include "../misc/Result.h" #include "../text/String.h" +#include + namespace water { //============================================================================== @@ -492,7 +494,7 @@ public: @see getNumberOfChildFiles, DirectoryIterator */ - int findChildFiles (Array& results, + int findChildFiles (std::vector& results, int whatToLookFor, bool searchRecursively, const String& wildCardPattern = "*") const; diff --git a/source/utils/CarlaDssiUtils.cpp b/source/utils/CarlaDssiUtils.cpp index ce33c858d..2b078e552 100644 --- a/source/utils/CarlaDssiUtils.cpp +++ b/source/utils/CarlaDssiUtils.cpp @@ -45,7 +45,7 @@ const char* find_dssi_ui(const char* const filename, const char* const label) no if (! checkLabel.endsWithChar('_')) checkLabel += "_"; if (! checkSName.endsWithChar('_')) checkSName += "_"; - water::Array results; + std::vector results; for (int i=water::File(pluginDir).findChildFiles(results, water::File::findFiles|water::File::ignoreHiddenFiles, false); --i >= 0;)