[FFmpeg-cvslog] avutil/dict: Avoid check whose result is known in advance

Andreas Rheinhardt git at videolan.org
Wed Sep 14 16:22:39 EEST 2022


ffmpeg | branch: master | Andreas Rheinhardt <andreas.rheinhardt at outlook.com> | Tue Sep 13 21:20:11 2022 +0200| [f976ed7fcf61324451e73876840c9473125f371b] | committer: Andreas Rheinhardt

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 <onemda at gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=f976ed7fcf61324451e73876840c9473125f371b
---

 libavutil/dict.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

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(&copy_key);
     }
-    if (!m->count) {
-        av_freep(&m->elems);
-        av_freep(pm);
-    }
 
     return 0;
 



More information about the ffmpeg-cvslog mailing list