summaryrefslogtreecommitdiff
path: root/libavcodec
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2013-12-06 15:24:10 +0100
committerMichael Niedermayer <michaelni@gmx.at>2013-12-06 15:27:36 +0100
commit133fbfc7811ffae7b97dd129fcd0b5e646742362 (patch)
tree9114fed08d3d1b9b801e702b25a40a1e1df47c8b /libavcodec
parent2b215f39391c0f9ddb547d16d568776e9e5da54d (diff)
do O(1) instead of O(n) atomic operations in register functions
about 1ms faster startup time Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec')
-rw-r--r--libavcodec/utils.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index 0397d3b68d..102a0490b0 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -206,7 +206,8 @@ av_cold void avcodec_register(AVCodec *codec)
avcodec_init();
p = &first_avcodec;
codec->next = NULL;
- while(avpriv_atomic_ptr_cas((void * volatile *)p, NULL, codec))
+
+ while(*p || avpriv_atomic_ptr_cas((void * volatile *)p, NULL, codec))
p = &(*p)->next;
if (codec->init_static_data)
@@ -3191,7 +3192,7 @@ void av_register_hwaccel(AVHWAccel *hwaccel)
{
AVHWAccel **p = &first_hwaccel;
hwaccel->next = NULL;
- while(avpriv_atomic_ptr_cas((void * volatile *)p, NULL, hwaccel))
+ while(*p || avpriv_atomic_ptr_cas((void * volatile *)p, NULL, hwaccel))
p = &(*p)->next;
}