From: Willy Tarreau Date: Mon, 1 Apr 2013 23:25:57 +0000 (+0200) Subject: OPTIM: buffer: remove one jump in buffer_count() X-Git-Tag: v1.5-dev18~41 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=bf43927cd70bd39b8bd57de5b61a3a273ada0f5e;p=thirdparty%2Fhaproxy.git OPTIM: buffer: remove one jump in buffer_count() We can help gcc build an expression not involving a jump. This function is used a lot when parsing chunks. --- diff --git a/include/common/buffer.h b/include/common/buffer.h index d46495c883..18ced917b2 100644 --- a/include/common/buffer.h +++ b/include/common/buffer.h @@ -272,8 +272,8 @@ static inline const char *buffer_pointer(const struct buffer *buf, const char *p static inline int buffer_count(const struct buffer *buf, const char *from, const char *to) { int count = to - from; - if (count < 0) - count += buf->size; + + count += count < 0 ? buf->size : 0; return count; }