diff options
author | wm4 <wm4@nowhere> | 2019-11-28 18:01:48 +0100 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2019-11-29 12:14:43 +0100 |
commit | 6d82c04dca8cc9c780725490607582684ba7a6e9 (patch) | |
tree | 9ed423d3f689f081022abacd23ee4f7bce1c5853 /player | |
parent | 63270ff898785814dd40a648362d540be8108464 (diff) | |
download | mpv-6d82c04dca8cc9c780725490607582684ba7a6e9.tar.bz2 mpv-6d82c04dca8cc9c780725490607582684ba7a6e9.tar.xz |
command: use m_option_equal()
No more converting the option values to a string to compare it.
Diffstat (limited to 'player')
-rw-r--r-- | player/command.c | 17 |
1 files changed, 1 insertions, 16 deletions
diff --git a/player/command.c b/player/command.c index 475552e28e..fea26dbdcf 100644 --- a/player/command.c +++ b/player/command.c @@ -4164,18 +4164,6 @@ static void change_property_cmd(struct mp_cmd_ctx *cmd, show_property_status(cmd, name, r); } -static bool compare_values(struct m_option *type, void *a, void *b) -{ - // Since there is no m_option_equals() or anything similar, we convert all - // values to a common, unambiguous representation - strings. - char *as = m_option_print(type, a); - char *bs = m_option_print(type, b); - bool res = bstr_equals(bstr0(as), bstr0(bs)); // treat as "" on failure - talloc_free(as); - talloc_free(bs); - return res; -} - static void cmd_cycle_values(void *p) { struct mp_cmd_ctx *cmd = p; @@ -4210,9 +4198,6 @@ static void cmd_cycle_values(void *p) return; } - // Find the current value. Note that we even though compare_values() uses - // strings internally, we need to convert the cycle-values arguments to - // native anyway to "normalize" the value for comparison. int current = -1; for (int n = first; n < cmd->num_args; n++) { union m_option_value val = {0}; @@ -4220,7 +4205,7 @@ static void cmd_cycle_values(void *p) bstr0(cmd->args[n].v.s), &val) < 0) continue; - if (compare_values(&prop, &curval, &val)) + if (m_option_equal(&prop, &curval, &val)) current = n; m_option_free(&prop, &val); |