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/blocks.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/blocks.c') diff --git a/src/blocks.c b/src/blocks.c index 5214f47..9970cc9 100644 --- a/src/blocks.c +++ b/src/blocks.c @@ -322,7 +322,8 @@ static cmark_node *finalize(cmark_parser *parser, cmark_node *b) { break; case CMARK_NODE_HTML_BLOCK: - b->as.literal = cmark_chunk_buf_detach(node_content); + b->as.literal.len = node_content->size; + b->as.literal.data = cmark_strbuf_detach(node_content); break; case CMARK_NODE_LIST: // determine tight/loose status -- cgit v1.2.3