diff options
author | Jordan Milne <jordan.milne@saynotolinux.com> | 2014-09-18 17:21:12 -0300 |
---|---|---|
committer | Jordan Milne <jordan.milne@saynotolinux.com> | 2014-09-18 17:40:34 -0300 |
commit | 2943b3850c5cb9e4561c3d109b4513a123bf4db7 (patch) | |
tree | 858d23d1b919ab47b86ed0a8e0a233b1565a1963 /src/inlines.c | |
parent | 41435824d9ff0212465d25f2e417c98e56a9e2c3 (diff) |
Use a lookup table for subject_find_special_char
Diffstat (limited to 'src/inlines.c')
-rw-r--r-- | src/inlines.c | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/src/inlines.c b/src/inlines.c index 145825c..71d75e9 100644 --- a/src/inlines.c +++ b/src/inlines.c @@ -768,13 +768,29 @@ node_inl *parse_chunk_inlines(chunk *chunk, reference_map *refmap) static int subject_find_special_char(subject *subj) { - static const char CHARS[] = "\n\\`&_*[]<!"; - static const size_t CHARS_SIZE = sizeof(CHARS) - 1; + // "\n\\`&_*[]<!" + static const int8_t SPECIAL_CHARS[256] = { + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, + 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; int n = subj->pos + 1; while (n < subj->input.len) { - if (memchr(CHARS, subj->input.data[n], CHARS_SIZE)) + if (SPECIAL_CHARS[subj->input.data[n]]) return n; n++; } |