diff options
author | John MacFarlane <jgm@berkeley.edu> | 2014-09-18 15:00:59 -0700 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2014-09-18 15:00:59 -0700 |
commit | ce1923214cd8cc9bd77068e6cb08a9d08a7e5495 (patch) | |
tree | 858d23d1b919ab47b86ed0a8e0a233b1565a1963 /src/inlines.c | |
parent | 41435824d9ff0212465d25f2e417c98e56a9e2c3 (diff) | |
parent | 2943b3850c5cb9e4561c3d109b4513a123bf4db7 (diff) |
Merge pull request #130 from JordanMilne/find_special_lookup
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++; } |