From f976ed7fcf61324451e73876840c9473125f371b Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Tue, 13 Sep 2022 21:20:11 +0200 Subject: avutil/dict: Avoid check whose result is known in advance We know that an AVDictionary is not empty if we have just added an entry to it, so only check for it being empty on the branch that does not do so. Reviewed-by: Paul B Mahol Signed-off-by: Andreas Rheinhardt --- libavutil/dict.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'libavutil/dict.c') diff --git a/libavutil/dict.c b/libavutil/dict.c index a4f638a1fc..d127bb90aa 100644 --- a/libavutil/dict.c +++ b/libavutil/dict.c @@ -126,12 +126,12 @@ int av_dict_set(AVDictionary **pm, const char *key, const char *value, } m->count++; } else { + if (!m->count) { + av_freep(&m->elems); + av_freep(pm); + } av_freep(©_key); } - if (!m->count) { - av_freep(&m->elems); - av_freep(pm); - } return 0; -- cgit v1.2.3