aboutsummaryrefslogtreecommitdiffstats
path: root/src/state.c
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2024-11-15 21:11:56 -0500
committerDavid Robillard <d@drobilla.net>2024-11-24 19:01:25 -0500
commit5f6531ef7edfef8b2056f5a6010603f00f210475 (patch)
tree1e819ab070b733737b3120fbae645d9631197aea /src/state.c
parentfb192806333ca88d5acb53b849f268611773230d (diff)
downloadjalv-5f6531ef7edfef8b2056f5a6010603f00f210475.tar.gz
jalv-5f6531ef7edfef8b2056f5a6010603f00f210475.tar.bz2
jalv-5f6531ef7edfef8b2056f5a6010603f00f210475.zip
Remove redundant condition
Reduce nesting in the implementation by ensuring that state is non-null at the caller.
Diffstat (limited to 'src/state.c')
-rw-r--r--src/state.c50
1 files changed, 26 insertions, 24 deletions
diff --git a/src/state.c b/src/state.c
index 1d473eb..27be61c 100644
--- a/src/state.c
+++ b/src/state.c
@@ -171,30 +171,30 @@ set_port_value(const char* port_symbol,
void
jalv_apply_state(Jalv* jalv, const LilvState* state)
{
- bool must_pause = !jalv->safe_restore && jalv->play_state == JALV_RUNNING;
- if (state) {
- if (must_pause) {
- jalv->play_state = JALV_PAUSE_REQUESTED;
- zix_sem_wait(&jalv->paused);
- }
+ const bool must_pause =
+ !jalv->safe_restore && jalv->play_state == JALV_RUNNING;
+ if (must_pause) {
+ jalv->play_state = JALV_PAUSE_REQUESTED;
+ zix_sem_wait(&jalv->paused);
+ }
- const LV2_Feature* state_features[9] = {
- &jalv->features.map_feature,
- &jalv->features.unmap_feature,
- &jalv->features.make_path_feature,
- &jalv->features.state_sched_feature,
- &jalv->features.safe_restore_feature,
- &jalv->features.log_feature,
- &jalv->features.options_feature,
- NULL};
-
- lilv_state_restore(
- state, jalv->instance, set_port_value, jalv, 0, state_features);
-
- if (must_pause) {
- jalv->request_update = true;
- jalv->play_state = JALV_RUNNING;
- }
+ const LV2_Feature* state_features[9] = {
+ &jalv->features.map_feature,
+ &jalv->features.unmap_feature,
+ &jalv->features.make_path_feature,
+ &jalv->features.state_sched_feature,
+ &jalv->features.safe_restore_feature,
+ &jalv->features.log_feature,
+ &jalv->features.options_feature,
+ NULL,
+ };
+
+ lilv_state_restore(
+ state, jalv->instance, set_port_value, jalv, 0, state_features);
+
+ if (must_pause) {
+ jalv->request_update = true;
+ jalv->play_state = JALV_RUNNING;
}
}
@@ -203,7 +203,9 @@ jalv_apply_preset(Jalv* jalv, const LilvNode* preset)
{
lilv_state_free(jalv->preset);
jalv->preset = lilv_state_new_from_world(jalv->world, &jalv->map, preset);
- jalv_apply_state(jalv, jalv->preset);
+ if (jalv->preset) {
+ jalv_apply_state(jalv, jalv->preset);
+ }
return 0;
}