From 5fb3803f4bf79f735fa92190e94d8e681450b0da Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Sun, 16 Dec 2012 19:39:09 +0100 Subject: [PATCH] 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. --- include/proto/channel.h | 2 +- src/buffer.c | 2 +- src/raw_sock.c | 2 +- src/ssl_sock.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/include/proto/channel.h b/include/proto/channel.h index eb40140f7..44cb89012 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 d7f7ae15d..60fb3fce5 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 4c83a6f88..20a867add 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 99f22f683..3e74ce546 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;