summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2019-11-28 18:01:48 +0100
committerwm4 <wm4@nowhere>2019-11-29 12:14:43 +0100
commit6d82c04dca8cc9c780725490607582684ba7a6e9 (patch)
tree9ed423d3f689f081022abacd23ee4f7bce1c5853
parent63270ff898785814dd40a648362d540be8108464 (diff)
downloadmpv-6d82c04dca8cc9c780725490607582684ba7a6e9.tar.bz2
mpv-6d82c04dca8cc9c780725490607582684ba7a6e9.tar.xz
command: use m_option_equal()
No more converting the option values to a string to compare it.
-rw-r--r--player/command.c17
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);