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/iterator.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/iterator.c') diff --git a/src/iterator.c b/src/iterator.c index f5cd802..cd7db8e 100644 --- a/src/iterator.c +++ b/src/iterator.c @@ -111,8 +111,9 @@ void cmark_consolidate_text_nodes(cmark_node *root) { cmark_node_free(tmp); tmp = next; } - cmark_chunk_free(iter->mem, &cur->as.literal); - cur->as.literal = cmark_chunk_buf_detach(&buf); + iter->mem->free(cur->as.literal.data); + cur->as.literal.len = buf.size; + cur->as.literal.data = cmark_strbuf_detach(&buf); } } -- cgit v1.2.3