mirror of
https://github.com/robbert-vdh/yabridge.git
synced 2026-05-10 04:30:12 +02:00
Use same style for optional and avoid double check
I did not know that `std::optional::value()` did checked access. And I still prefer a more explicit .has_value() over boolean conversion, but this seems to be the accepted way to do this.
This commit is contained in:
@@ -245,10 +245,9 @@ void Vst2Bridge::handle_parameters() {
|
||||
// presence of the `value` field tells us which one we're dealing
|
||||
// with.
|
||||
auto request = read_object<Parameter>(host_vst_parameters);
|
||||
if (request.value.has_value()) {
|
||||
if (request.value) {
|
||||
// `setParameter`
|
||||
plugin->setParameter(plugin, request.index,
|
||||
request.value.value());
|
||||
plugin->setParameter(plugin, request.index, *request.value);
|
||||
|
||||
ParameterResult response{std::nullopt};
|
||||
write_object(host_vst_parameters, response);
|
||||
@@ -477,8 +476,8 @@ class HostCallbackDataConverter : DefaultDataConverter {
|
||||
// Return a pointer to the `VstTimeInfo` object written in
|
||||
// the function above
|
||||
VstTimeInfo* time_info_pointer = nullptr;
|
||||
if (time_info.has_value()) {
|
||||
time_info_pointer = &time_info.value();
|
||||
if (time_info) {
|
||||
time_info_pointer = &*time_info;
|
||||
}
|
||||
|
||||
return reinterpret_cast<intptr_t>(time_info_pointer);
|
||||
|
||||
@@ -26,8 +26,8 @@ Win32Timer::Win32Timer(HWND window_handle,
|
||||
}
|
||||
|
||||
Win32Timer::~Win32Timer() {
|
||||
if (timer_id.has_value()) {
|
||||
KillTimer(window_handle, timer_id.value());
|
||||
if (timer_id) {
|
||||
KillTimer(window_handle, *timer_id);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user