mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-01-13 21:28:01 +02:00
change while loops to do-while as the condition is true the first time and the check just wastes cpu cycles
Originally committed as revision 7576 to svn://svn.ffmpeg.org/ffmpeg/trunk
This commit is contained in:
parent
4497712f09
commit
50b4468598
@ -73,7 +73,7 @@ void av_fifo_realloc(AVFifoBuffer *f, unsigned int new_size) {
|
|||||||
|
|
||||||
void av_fifo_write(AVFifoBuffer *f, const uint8_t *buf, int size)
|
void av_fifo_write(AVFifoBuffer *f, const uint8_t *buf, int size)
|
||||||
{
|
{
|
||||||
while (size > 0) {
|
do {
|
||||||
int len = FFMIN(f->end - f->wptr, size);
|
int len = FFMIN(f->end - f->wptr, size);
|
||||||
memcpy(f->wptr, buf, len);
|
memcpy(f->wptr, buf, len);
|
||||||
f->wptr += len;
|
f->wptr += len;
|
||||||
@ -81,7 +81,7 @@ void av_fifo_write(AVFifoBuffer *f, const uint8_t *buf, int size)
|
|||||||
f->wptr = f->buffer;
|
f->wptr = f->buffer;
|
||||||
buf += len;
|
buf += len;
|
||||||
size -= len;
|
size -= len;
|
||||||
}
|
} while (size > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -92,7 +92,7 @@ int av_fifo_generic_read(AVFifoBuffer *f, int buf_size, void (*func)(void*, void
|
|||||||
|
|
||||||
if (size < buf_size)
|
if (size < buf_size)
|
||||||
return -1;
|
return -1;
|
||||||
while (buf_size > 0) {
|
do {
|
||||||
int len = FFMIN(f->end - f->rptr, buf_size);
|
int len = FFMIN(f->end - f->rptr, buf_size);
|
||||||
if(func) func(dest, f->rptr, len);
|
if(func) func(dest, f->rptr, len);
|
||||||
else{
|
else{
|
||||||
@ -101,7 +101,7 @@ int av_fifo_generic_read(AVFifoBuffer *f, int buf_size, void (*func)(void*, void
|
|||||||
}
|
}
|
||||||
av_fifo_drain(f, len);
|
av_fifo_drain(f, len);
|
||||||
buf_size -= len;
|
buf_size -= len;
|
||||||
}
|
} while (buf_size > 0);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user