commit 443ee51581461be7c8f5fdbcec0c4f3681e0c50b parent 7cb7f65cf09b17041770d8c39f04e0842757ae4f Author: Martin Mitas <mity@morous.org> Date: Sun, 1 Jan 2017 21:39:48 +0100 md_collect_marks: Optimize the fast path by making its loops tighter. Diffstat:
| M | md4c/md4c.c | | | 16 | ++++++++-------- |
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/md4c/md4c.c b/md4c/md4c.c @@ -2439,22 +2439,22 @@ md_collect_marks(MD_CTX* ctx, const MD_LINE* lines, int n_lines, int table_mode) OFF off = line->beg; OFF line_end = line->end; - while(off < line_end) { + while(TRUE) { CHAR ch; /* Optimization: Fast path (with some loop unrolling). */ - if(off + 4 < line_end && + while(off + 4 < line_end && ((unsigned)CH(off+0) >= sizeof(ctx->mark_char_map) || !ctx->mark_char_map[(unsigned) CH(off+0)]) && ((unsigned)CH(off+1) >= sizeof(ctx->mark_char_map) || !ctx->mark_char_map[(unsigned) CH(off+1)]) && ((unsigned)CH(off+2) >= sizeof(ctx->mark_char_map) || !ctx->mark_char_map[(unsigned) CH(off+2)]) && - ((unsigned)CH(off+3) >= sizeof(ctx->mark_char_map) || !ctx->mark_char_map[(unsigned) CH(off+3)])) { + ((unsigned)CH(off+3) >= sizeof(ctx->mark_char_map) || !ctx->mark_char_map[(unsigned) CH(off+3)])) off += 4; - continue; - } - if((unsigned)CH(off+0) >= sizeof(ctx->mark_char_map) || !ctx->mark_char_map[(unsigned) CH(off+0)]) { + while(off < line_end && + ((unsigned)CH(off+0) >= sizeof(ctx->mark_char_map) || !ctx->mark_char_map[(unsigned) CH(off+0)])) off++; - continue; - } + + if(off >= line_end) + break; ch = CH(off);