summaryrefslogtreecommitdiff
path: root/libavutil/fifo.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2007-01-18 00:22:24 +0000
committerMichael Niedermayer <michaelni@gmx.at>2007-01-18 00:22:24 +0000
commit50b4468598cbc032c0ec4597df9637f71b9ef664 (patch)
treec66f6eca92dffbf8f31b78fdf0732e4dd3e44b3b /libavutil/fifo.c
parent4497712f091690948c7ddaf8ffd01202dfef9931 (diff)
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
Diffstat (limited to 'libavutil/fifo.c')
-rw-r--r--libavutil/fifo.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/libavutil/fifo.c b/libavutil/fifo.c
index b86d2629ee..8ac3a0cb55 100644
--- a/libavutil/fifo.c
+++ b/libavutil/fifo.c
@@ -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)
{
- while (size > 0) {
+ do {
int len = FFMIN(f->end - f->wptr, size);
memcpy(f->wptr, buf, len);
f->wptr += len;
@@ -81,7 +81,7 @@ void av_fifo_write(AVFifoBuffer *f, const uint8_t *buf, int size)
f->wptr = f->buffer;
buf += 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)
return -1;
- while (buf_size > 0) {
+ do {
int len = FFMIN(f->end - f->rptr, buf_size);
if(func) func(dest, f->rptr, len);
else{
@@ -101,7 +101,7 @@ int av_fifo_generic_read(AVFifoBuffer *f, int buf_size, void (*func)(void*, void
}
av_fifo_drain(f, len);
buf_size -= len;
- }
+ } while (buf_size > 0);
return 0;
}