History

do O(1) instead of O(n) atomic operations in register functions

about 1ms faster startup time

Michael Niedermayer committed 12 years ago

Commit 133fbfc1 parent 2b215f33 files · +6 −5Browse files

Unified · Split

3 files
  1. libavcodec/utils.c +3 −2
  2. libavfilter/avfilter.c +1 −1
  3. libavformat/format.c +2 −2
libavcodec/utils.c+3−2
@@ -206,7 +206,8 @@ av_cold void avcodec_register(AVCodec *codec) · 205 unmodified lines
206 avcodec_init();206 avcodec_init();
207 p = &first_avcodec;207 p = &first_avcodec;
208 codec->next = NULL;208 codec->next = NULL;
209 while(avpriv_atomic_ptr_cas((void * volatile *)p, NULL, codec))209
210 while(*p || avpriv_atomic_ptr_cas((void * volatile *)p, NULL, codec))
210 p = &(*p)->next;211 p = &(*p)->next;
211 212
212 if (codec->init_static_data)213 if (codec->init_static_data)
@@ -3191,7 +3192,7 @@ void av_register_hwaccel(AVHWAccel *hwaccel) · 2978 unmodified lines
3191{3192{
3192 AVHWAccel **p = &first_hwaccel;3193 AVHWAccel **p = &first_hwaccel;
3193 hwaccel->next = NULL;3194 hwaccel->next = NULL;
3194 while(avpriv_atomic_ptr_cas((void * volatile *)p, NULL, hwaccel))3195 while(*p || avpriv_atomic_ptr_cas((void * volatile *)p, NULL, hwaccel))
3195 p = &(*p)->next;3196 p = &(*p)->next;
3196}3197}
3197 3198
libavfilter/avfilter.c+1−1
@@ -490,7 +490,7 @@ int avfilter_register(AVFilter *filter) · 489 unmodified lines
490 490
491 filter->next = NULL;491 filter->next = NULL;
492 492
493 while(avpriv_atomic_ptr_cas((void * volatile *)f, NULL, filter))493 while(*f || avpriv_atomic_ptr_cas((void * volatile *)f, NULL, filter))
494 f = &(*f)->next;494 f = &(*f)->next;
495 495
496 return 0;496 return 0;
libavformat/format.c+2−2
@@ -54,7 +54,7 @@ void av_register_input_format(AVInputFormat *format) · 53 unmodified lines
54 AVInputFormat **p = &first_iformat;54 AVInputFormat **p = &first_iformat;
55 55
56 format->next = NULL;56 format->next = NULL;
57 while(avpriv_atomic_ptr_cas((void * volatile *)p, NULL, format))57 while(*p || avpriv_atomic_ptr_cas((void * volatile *)p, NULL, format))
58 p = &(*p)->next;58 p = &(*p)->next;
59}59}
60 60
@@ -63,7 +63,7 @@ void av_register_output_format(AVOutputFormat *format) · 2 unmodified lines
63 AVOutputFormat **p = &first_oformat;63 AVOutputFormat **p = &first_oformat;
64 64
65 format->next = NULL;65 format->next = NULL;
66 while(avpriv_atomic_ptr_cas((void * volatile *)p, NULL, format))66 while(*p || avpriv_atomic_ptr_cas((void * volatile *)p, NULL, format))
67 p = &(*p)->next;67 p = &(*p)->next;
68}68}
69 69

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t