From 78fe41f2462ae7e92eb68a9173082d561354b808 Mon Sep 17 00:00:00 2001 From: wm4 Date: Tue, 1 May 2018 03:51:14 +0200 Subject: 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. --- player/command.c | 35 +++++++++++++---------------------- 1 file 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; } } -- cgit v1.2.3