From 27e20662292688639a3a141c843b99e12fc7fe11 Mon Sep 17 00:00:00 2001 From: Ran Benita Date: Sat, 8 Feb 2014 12:31:21 +0200 Subject: [PATCH] scanner-utils: add some likely/unlikely annotations Signed-off-by: Ran Benita --- src/xkbcomp/scanner-utils.h | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/xkbcomp/scanner-utils.h b/src/xkbcomp/scanner-utils.h index 7e21b00..13de976 100644 --- a/src/xkbcomp/scanner-utils.h +++ b/src/xkbcomp/scanner-utils.h @@ -72,7 +72,9 @@ scanner_init(struct scanner *s, struct xkb_context *ctx, static inline char peek(struct scanner *s) { - return s->pos < s->len ? s->s[s->pos] : '\0'; + if (unlikely(s->pos >= s->len)) + return '\0'; + return s->s[s->pos]; } static inline bool @@ -90,9 +92,9 @@ eol(struct scanner *s) static inline char next(struct scanner *s) { - if (eof(s)) + if (unlikely(eof(s))) return '\0'; - if (eol(s)) { + if (unlikely(eol(s))) { s->line++; s->column = 1; } @@ -105,7 +107,7 @@ next(struct scanner *s) static inline bool chr(struct scanner *s, char ch) { - if (peek(s) != ch) + if (likely(peek(s) != ch)) return false; s->pos++; s->column++; return true;