From 133fbfc7811ffae7b97dd129fcd0b5e646742362 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Fri, 6 Dec 2013 15:24:10 +0100 Subject: do O(1) instead of O(n) atomic operations in register functions about 1ms faster startup time Signed-off-by: Michael Niedermayer --- libavformat/format.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'libavformat/format.c') diff --git a/libavformat/format.c b/libavformat/format.c index ac9100b604..36c0131c12 100644 --- a/libavformat/format.c +++ b/libavformat/format.c @@ -54,7 +54,7 @@ void av_register_input_format(AVInputFormat *format) AVInputFormat **p = &first_iformat; format->next = NULL; - while(avpriv_atomic_ptr_cas((void * volatile *)p, NULL, format)) + while(*p || avpriv_atomic_ptr_cas((void * volatile *)p, NULL, format)) p = &(*p)->next; } @@ -63,7 +63,7 @@ void av_register_output_format(AVOutputFormat *format) AVOutputFormat **p = &first_oformat; format->next = NULL; - while(avpriv_atomic_ptr_cas((void * volatile *)p, NULL, format)) + while(*p || avpriv_atomic_ptr_cas((void * volatile *)p, NULL, format)) p = &(*p)->next; } -- cgit v1.2.3