Also use hashsets for the VST2 opcode dispatch

Should barely make a difference, but it should be as fast or faster.
This commit is contained in:
Robbert van der Helm
2021-06-11 14:57:01 +02:00
parent aaf3e7438c
commit 78f6921cd8
4 changed files with 12 additions and 10 deletions
+1
View File
@@ -16,6 +16,7 @@ Versioning](https://semver.org/spec/v2.0.0.html).
during audio processing should now be about as low as it's going to get.
- Optimized the management of VST3 plugin instances to reduce the overhead when
using many instances of a VST3 plugin.
- Slightly optimized the function call dispatch for VST2 plugins.
- Prevented some more potential unnecessary memory operations during yabridge's
communication. The underlying serialization library was recreating some
objects even when that wasn't needed, which could in theory result in memory
+6 -5
View File
@@ -64,7 +64,7 @@ Vst2Bridge* current_bridge_instance = nullptr;
* `audioMasterUpdateDisplay()`, and PG-8X also requires that to be called
* from the same thread that called `audioMasterUpdateDisplay()`.
*/
static const std::set<int> mutually_recursive_callbacks{
static const std::unordered_set<int> mutually_recursive_callbacks{
audioMasterUpdateDisplay};
/**
@@ -78,8 +78,8 @@ static const std::set<int> mutually_recursive_callbacks{
* just execute the function directly on the calling thread. See above for a
* list of situations where this may be necessary.
*/
static const std::set<int> safe_mutually_recursive_requests{effGetProgram,
effGetProgramName};
static const std::unordered_set<int> safe_mutually_recursive_requests{
effGetProgram, effGetProgramName};
/**
* Opcodes that should always be handled on the main thread because they may
@@ -92,7 +92,7 @@ static const std::set<int> safe_mutually_recursive_requests{effGetProgram,
* Algonaut Atlas doesn't restore chunk data unless `effSetChunk` is run
* from the GUI thread
*/
static const std::set<int> unsafe_requests{
static const std::unordered_set<int> unsafe_requests{
effOpen, effClose, effEditGetRect, effEditOpen, effEditClose,
effEditIdle, effEditTop, effMainsChanged, effGetChunk, effSetChunk};
@@ -103,7 +103,8 @@ static const std::set<int> unsafe_requests{
* implement thread priorities. Normally these unsafe requests are run on the
* main thread, which doesn't use realtime scheduling.
*/
static const std::set<int> unsafe_requests_realtime{effOpen, effMainsChanged};
static const std::unordered_set<int> unsafe_requests_realtime{effOpen,
effMainsChanged};
intptr_t VST_CALL_CONV
host_callback_proxy(AEffect*, int, int, intptr_t, void*, float);
+1 -1
View File
@@ -108,7 +108,7 @@ void MainContext::update_timer_interval(
MainContext::WatchdogGuard::WatchdogGuard(
HostBridge& bridge,
std::set<HostBridge*>& watched_bridges,
std::unordered_set<HostBridge*>& watched_bridges,
std::mutex& watched_bridges_mutex)
: bridge(&bridge),
watched_bridges(watched_bridges),
+4 -4
View File
@@ -21,7 +21,7 @@
#include <future>
#include <memory>
#include <optional>
#include <set>
#include <unordered_set>
#include <windows.h>
#include <boost/asio/dispatch.hpp>
@@ -195,7 +195,7 @@ class MainContext {
class WatchdogGuard {
public:
WatchdogGuard(HostBridge& bridge,
std::set<HostBridge*>& watched_bridges,
std::unordered_set<HostBridge*>& watched_bridges,
std::mutex& watched_bridges_mutex);
~WatchdogGuard() noexcept;
@@ -220,7 +220,7 @@ class MainContext {
// References to the same two fields on `MainContext`, so we don't have
// to use `friend`
std::reference_wrapper<std::set<HostBridge*>> watched_bridges;
std::reference_wrapper<std::unordered_set<HostBridge*>> watched_bridges;
std::reference_wrapper<std::mutex> watched_bridges_mutex;
};
@@ -349,7 +349,7 @@ class MainContext {
* pointers for efficiency's sake, since reference wrappers don't implement
* any comparison operators.
*/
std::set<HostBridge*> watched_bridges;
std::unordered_set<HostBridge*> watched_bridges;
std::mutex watched_bridges_mutex;
/**