scanner-utils: add some likely/unlikely annotations
Signed-off-by: Ran Benita <ran234@gmail.com>master
parent
10643d8aa4
commit
27e2066229
|
@ -72,7 +72,9 @@ scanner_init(struct scanner *s, struct xkb_context *ctx,
|
||||||
static inline char
|
static inline char
|
||||||
peek(struct scanner *s)
|
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
|
static inline bool
|
||||||
|
@ -90,9 +92,9 @@ eol(struct scanner *s)
|
||||||
static inline char
|
static inline char
|
||||||
next(struct scanner *s)
|
next(struct scanner *s)
|
||||||
{
|
{
|
||||||
if (eof(s))
|
if (unlikely(eof(s)))
|
||||||
return '\0';
|
return '\0';
|
||||||
if (eol(s)) {
|
if (unlikely(eol(s))) {
|
||||||
s->line++;
|
s->line++;
|
||||||
s->column = 1;
|
s->column = 1;
|
||||||
}
|
}
|
||||||
|
@ -105,7 +107,7 @@ next(struct scanner *s)
|
||||||
static inline bool
|
static inline bool
|
||||||
chr(struct scanner *s, char ch)
|
chr(struct scanner *s, char ch)
|
||||||
{
|
{
|
||||||
if (peek(s) != ch)
|
if (likely(peek(s) != ch))
|
||||||
return false;
|
return false;
|
||||||
s->pos++; s->column++;
|
s->pos++; s->column++;
|
||||||
return true;
|
return true;
|
||||||
|
|
Loading…
Reference in New Issue