mirror of
https://github.com/robbert-vdh/yabridge.git
synced 2026-05-16 13:40:05 +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;
|
return Steinberg::kInvalidArgument;
|
||||||
}
|
}
|
||||||
|
|
||||||
// On the first call to this, we'll reconstruct `Event` objects out of our
|
// Reconstructing an event is cheap, but some events may contain pointers to
|
||||||
// `YaEvent`s all at once. This is also done if for whatever reason the
|
// heap data stored within the `events` vector so this event will still have
|
||||||
// plugin `getEvent()`s an event it just added.
|
// the same lifetime as this class
|
||||||
const size_t num_already_reconstructed_events = reconstructed_events.size();
|
e = events[index].get();
|
||||||
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];
|
|
||||||
|
|
||||||
return Steinberg::kResultOk;
|
return Steinberg::kResultOk;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -257,21 +257,10 @@ class YaEventList : public Steinberg::Vst::IEventList {
|
|||||||
template <typename S>
|
template <typename S>
|
||||||
void serialize(S& s) {
|
void serialize(S& s) {
|
||||||
s.container(events, 1 << 16);
|
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:
|
private:
|
||||||
boost::container::small_vector<YaEvent, 64> events;
|
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
|
#pragma GCC diagnostic pop
|
||||||
|
|||||||
Reference in New Issue
Block a user