[FFmpeg-devel] [PATCH 3/5] lavu/dict: use intermediate variable for value assignment.

Clément Bœsch ubitux at gmail.com
Sun Apr 14 03:07:56 CEST 2013


---
 libavutil/dict.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/libavutil/dict.c b/libavutil/dict.c
index 3a0e84c..64ddffd 100644
--- a/libavutil/dict.c
+++ b/libavutil/dict.c
@@ -85,12 +85,14 @@ int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags
             return AVERROR(ENOMEM);
     }
     if (value) {
+        AVDictionaryEntry *e = &m->elems[m->count++];
+
         if (flags & AV_DICT_DONT_STRDUP_KEY) {
-            m->elems[m->count].key = (char*)(intptr_t)key;
+            e->key = (char*)(intptr_t)key;
         } else
-            m->elems[m->count].key = av_strdup(key);
+            e->key = av_strdup(key);
         if (flags & AV_DICT_DONT_STRDUP_VAL) {
-            m->elems[m->count].value = (char*)(intptr_t)value;
+            e->value = (char*)(intptr_t)value;
         } else if (oldval && flags & AV_DICT_APPEND) {
             int len = strlen(oldval) + strlen(value) + 1;
             char *newval = av_mallocz(len);
@@ -99,10 +101,9 @@ int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags
             av_strlcat(newval, oldval, len);
             av_freep(&oldval);
             av_strlcat(newval, value, len);
-            m->elems[m->count].value = newval;
+            e->value = newval;
         } else
-            m->elems[m->count].value = av_strdup(value);
-        m->count++;
+            e->value = av_strdup(value);
     }
     if (!m->count) {
         av_free(m->elems);
-- 
1.8.2.1



More information about the ffmpeg-devel mailing list