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/node.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/node.h') diff --git a/src/node.h b/src/node.h index b557f12..fbf449c 100644 --- a/src/node.h +++ b/src/node.h @@ -10,7 +10,11 @@ extern "C" { #include "cmark.h" #include "buffer.h" -#include "chunk.h" + +typedef struct { + unsigned char *data; + bufsize_t len; +} cmark_literal; typedef struct { cmark_list_type list_type; @@ -72,7 +76,7 @@ struct cmark_node { uint16_t flags; union { - cmark_chunk literal; + cmark_literal literal; cmark_list list; cmark_code code; cmark_heading heading; -- cgit v1.2.3