From b0a4cfa36e99c27dd2b20be8f8888fa7721bad58 Mon Sep 17 00:00:00 2001 From: Nick Wellnhofer Date: Sun, 19 Jan 2020 00:51:02 +0100 Subject: Use C string instead of chunk for literal text Use zero-terminated C strings and a separate length field instead of cmark_chunks. Literal inline text will now be copied from the parent block's content buffer, slowing the benchmark down by 10-15%. The node struct never references memory of other nodes now, fixing #309. Node accessors don't have to check for delayed creation of C strings, so parsing and iterating all literals using the public API should actually be faster than before. --- src/commonmark.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/commonmark.c') diff --git a/src/commonmark.c b/src/commonmark.c index 89aef5b..41bfa52 100644 --- a/src/commonmark.c +++ b/src/commonmark.c @@ -146,8 +146,7 @@ static bool is_autolink(cmark_node *node) { if (strcmp((const char *)url, "mailto:") == 0) { url += 7; } - return strncmp((const char *)url, (char *)link_text->as.literal.data, - link_text->as.literal.len) == 0; + return strcmp((const char *)url, (char *)link_text->as.literal.data) == 0; } // if node is a block node, returns node. -- cgit v1.2.3