Signed-off-by: Ran Benita <ran234@gmail.com>
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
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;
}
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;