summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJordan Milne <jordan.milne@saynotolinux.com>2014-09-18 17:21:12 -0300
committerJordan Milne <jordan.milne@saynotolinux.com>2014-09-18 17:40:34 -0300
commit2943b3850c5cb9e4561c3d109b4513a123bf4db7 (patch)
tree858d23d1b919ab47b86ed0a8e0a233b1565a1963
parent41435824d9ff0212465d25f2e417c98e56a9e2c3 (diff)
Use a lookup table for subject_find_special_char
-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++;
}