summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2018-05-01 03:51:14 +0200
committerJan Ekström <jeebjp@gmail.com>2018-05-03 01:20:01 +0300
commit78fe41f2462ae7e92eb68a9173082d561354b808 (patch)
tree5282d1802efca4254804b6b9e4e9d7e5e6b7eeef
parent88498bcc92305dccb8a73104f7996dd4253a0a2d (diff)
downloadmpv-78fe41f2462ae7e92eb68a9173082d561354b808.tar.bz2
mpv-78fe41f2462ae7e92eb68a9173082d561354b808.tar.xz
command: simplify option property init
The "if (prop.name)" check is redundant, because an assert above it implies that it never can be NULL. Deduplicate some code for initializing the "prop" variable.
-rw-r--r--player/command.c35
1 files changed, 13 insertions, 22 deletions
diff --git a/player/command.c b/player/command.c
index d5cedb235a..b15fd7ff80 100644
--- a/player/command.c
+++ b/player/command.c
@@ -6083,33 +6083,24 @@ void command_init(struct MPContext *mpctx)
if (co->opt->flags & M_OPT_NOPROP)
continue;
- struct m_property prop = {0};
+ struct m_property prop = {
+ .name = co->name,
+ .call = mp_property_generic_option,
+ .is_option = true,
+ };
if (co->opt->type == &m_option_type_alias) {
- const char *alias = (const char *)co->opt->priv;
-
- prop = (struct m_property){
- .name = co->name,
- .call = co->opt->deprecation_message ?
- mp_property_deprecated_alias : mp_property_alias,
- .priv = (void *)alias,
- .is_option = true,
- };
- } else {
- prop = (struct m_property){
- .name = co->name,
- .call = mp_property_generic_option,
- .is_option = true,
- };
+ prop.priv = co->opt->priv;
+
+ prop.call = co->opt->deprecation_message ?
+ mp_property_deprecated_alias : mp_property_alias;
}
- if (prop.name) {
- // The option might be covered by a manual property already.
- if (m_property_list_find(ctx->properties, prop.name))
- continue;
+ // The option might be covered by a manual property already.
+ if (m_property_list_find(ctx->properties, prop.name))
+ continue;
- ctx->properties[count++] = prop;
- }
+ ctx->properties[count++] = prop;
}
}