summaryrefslogtreecommitdiff
path: root/src/inlines.c
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2014-09-18 15:00:59 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2014-09-18 15:00:59 -0700
commitce1923214cd8cc9bd77068e6cb08a9d08a7e5495 (patch)
tree858d23d1b919ab47b86ed0a8e0a233b1565a1963 /src/inlines.c
parent41435824d9ff0212465d25f2e417c98e56a9e2c3 (diff)
parent2943b3850c5cb9e4561c3d109b4513a123bf4db7 (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.c22
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++;
}