From: Willy Tarreau Date: Sun, 16 Dec 2012 18:39:09 +0000 (+0100) Subject: CLEANUP: buffer: use buffer_empty() instead of buffer_len()==0 X-Git-Tag: v1.5-dev16~27 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5fb3803f4bf79f735fa92190e94d8e681450b0da;p=thirdparty%2Fhaproxy.git CLEANUP: buffer: use buffer_empty() instead of buffer_len()==0 A few places still made use of buffer_len()==0 to detect an empty buffer. Use the cleaner and more efficient buffer_empty() instead. --- diff --git a/include/proto/channel.h b/include/proto/channel.h index eb40140f7c..44cb890123 100644 --- a/include/proto/channel.h +++ b/include/proto/channel.h @@ -327,7 +327,7 @@ static inline void bo_skip(struct channel *chn, int len) { chn->buf->o -= len; - if (buffer_len(chn->buf) == 0) + if (buffer_empty(chn->buf)) chn->buf->p = chn->buf->data; /* notify that some data was written to the SI from the buffer */ diff --git a/src/buffer.c b/src/buffer.c index d7f7ae15da..60fb3fce52 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -63,7 +63,7 @@ int buffer_replace2(struct buffer *b, char *pos, char *end, const char *str, int b->i += delta; - if (buffer_len(b) == 0) + if (buffer_empty(b)) b->p = b->data; return delta; diff --git a/src/raw_sock.c b/src/raw_sock.c index 4c83a6f88e..20a867add0 100644 --- a/src/raw_sock.c +++ b/src/raw_sock.c @@ -331,7 +331,7 @@ static int raw_sock_from_buf(struct connection *conn, struct buffer *buf, int fl buf->o -= ret; done += ret; - if (likely(!buffer_len(buf))) + if (likely(buffer_empty(buf))) /* optimize data alignment in the buffer */ buf->p = buf->data; diff --git a/src/ssl_sock.c b/src/ssl_sock.c index 99f22f6839..3e74ce5463 100644 --- a/src/ssl_sock.c +++ b/src/ssl_sock.c @@ -1167,7 +1167,7 @@ static int ssl_sock_from_buf(struct connection *conn, struct buffer *buf, int fl buf->o -= ret; done += ret; - if (likely(!buffer_len(buf))) + if (likely(buffer_empty(buf))) /* optimize data alignment in the buffer */ buf->p = buf->data;