Mercurial > libavutil.hg
changeset 230:4c85ac99ab37 libavutil
change while loops to do-while as the condition is true the first time and the check just wastes cpu cycles
author | michael |
---|---|
date | Thu, 18 Jan 2007 00:22:24 +0000 |
parents | 3f5c648b82c4 |
children | 33b71496b63b |
files | fifo.c |
diffstat | 1 files changed, 4 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/fifo.c Wed Jan 17 20:14:02 2007 +0000 +++ b/fifo.c Thu Jan 18 00:22:24 2007 +0000 @@ -73,7 +73,7 @@ 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 @@ f->wptr = f->buffer; buf += len; size -= len; - } + } while (size > 0); } @@ -92,7 +92,7 @@ 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 @@ } av_fifo_drain(f, len); buf_size -= len; - } + } while (buf_size > 0); return 0; }