]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
OPTIM: buffer: remove one jump in buffer_count()
authorWilly Tarreau <w@1wt.eu>
Mon, 1 Apr 2013 23:25:57 +0000 (01:25 +0200)
committerWilly Tarreau <w@1wt.eu>
Mon, 1 Apr 2013 23:25:57 +0000 (01:25 +0200)
We can help gcc build an expression not involving a jump. This function
is used a lot when parsing chunks.

include/common/buffer.h

index d46495c883f2f8e5bce16e78b781403c5dc66c68..18ced917b2849c48de1a3a1ea76ba0f237e66399 100644 (file)
@@ -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;
 }