[FFmpeg-devel] Optimize libavformat/metadata.c

Submitted by Shlomi Fish on July 4, 2018, 8:10 p.m.

Details

Message ID 20180704231046.1fe7845a@telaviv1.shlomifish.org
State New
Headers show

Commit Message

Shlomi Fish July 4, 2018, 8:10 p.m.

Comments

Shlomi Fish July 11, 2018, 4:42 p.m.
On Wed, 4 Jul 2018 23:10:46 +0300
Shlomi Fish <shlomif@shlomifish.org> wrote:

Ping! Can this patch be reviewed please?

Patch hide | download patch | download mbox

From 98e0629d28394f8683abd98f80645ee63b295d24 Mon Sep 17 00:00:00 2001
From: Shlomi Fish <shlomif@shlomifish.org>
Date: Wed, 4 Jul 2018 22:53:08 +0300
Subject: [PATCH] Short-circuit several calls on a condition.

This is an optimization - more details in the comment in the changeset.
---
 libavformat/metadata.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/libavformat/metadata.c b/libavformat/metadata.c
index b9b6de7972..4b720efd38 100644
--- a/libavformat/metadata.c
+++ b/libavformat/metadata.c
@@ -60,6 +60,10 @@  void ff_metadata_conv_ctx(AVFormatContext *ctx, const AVMetadataConv *d_conv,
                                                 const AVMetadataConv *s_conv)
 {
     int i;
+    /* We pass those to all ff_metadata_conv calls below and it returns
+     * immediately if they are equal, so we can short-circuit. */
+    if (d_conv == s_conv)
+        return;
     ff_metadata_conv(&ctx->metadata, d_conv, s_conv);
     for (i=0; i<ctx->nb_streams ; i++)
         ff_metadata_conv(&ctx->streams [i]->metadata, d_conv, s_conv);
-- 
2.18.0