mirror of
https://github.com/robbert-vdh/yabridge.git
synced 2026-05-07 03:50:11 +02:00
Don't cache reconstructed VST3 events at all
There's no need to since reconstructing the event is very cheap, and this should be faster (less memory used) and also less error prone anyways.
This commit is contained in:
@@ -227,21 +227,10 @@ tresult PLUGIN_API YaEventList::getEvent(int32 index,
|
||||
return Steinberg::kInvalidArgument;
|
||||
}
|
||||
|
||||
// On the first call to this, we'll reconstruct `Event` objects out of our
|
||||
// `YaEvent`s all at once. This is also done if for whatever reason the
|
||||
// plugin `getEvent()`s an event it just added.
|
||||
const size_t num_already_reconstructed_events = reconstructed_events.size();
|
||||
if (index >= static_cast<int32>(num_already_reconstructed_events)) {
|
||||
reconstructed_events.resize(events.size());
|
||||
std::transform(
|
||||
events.begin() + static_cast<int>(num_already_reconstructed_events),
|
||||
events.end(),
|
||||
reconstructed_events.begin() +
|
||||
static_cast<int>(num_already_reconstructed_events),
|
||||
[](const YaEvent& event) { return event.get(); });
|
||||
}
|
||||
|
||||
e = reconstructed_events[index];
|
||||
// Reconstructing an event is cheap, but some events may contain pointers to
|
||||
// heap data stored within the `events` vector so this event will still have
|
||||
// the same lifetime as this class
|
||||
e = events[index].get();
|
||||
|
||||
return Steinberg::kResultOk;
|
||||
}
|
||||
|
||||
@@ -257,21 +257,10 @@ class YaEventList : public Steinberg::Vst::IEventList {
|
||||
template <typename S>
|
||||
void serialize(S& s) {
|
||||
s.container(events, 1 << 16);
|
||||
|
||||
// NOTE: After deserializing events, we need to make sure to clear our
|
||||
// caches since those may still contain old events
|
||||
reconstructed_events.clear();
|
||||
}
|
||||
|
||||
private:
|
||||
boost::container::small_vector<YaEvent, 64> events;
|
||||
|
||||
/**
|
||||
* On the first `getEvent()` call we'll reconstruct these from `events` all
|
||||
* at once. These event objects may not outlive this event list.
|
||||
*/
|
||||
boost::container::small_vector<Steinberg::Vst::Event, 64>
|
||||
reconstructed_events;
|
||||
};
|
||||
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
Reference in New Issue
Block a user