From f3f50b29d615d2678d8047dc277b108cc5143167 Mon Sep 17 00:00:00 2001 From: Nick Wellnhofer Date: Sun, 19 Jan 2020 13:46:10 +0100 Subject: Rearrange struct cmark_node Introduce multi-purpose data/len members in struct cmark_node. This is mainly used to store literal text for inlines, code and HTML blocks. Move the content strbuf for blocks from cmark_node to cmark_parser. When finalizing nodes that allow inlines (paragraphs and headings), detach the strbuf and store the block content in the node's data/len members. Free the block content after processing inlines. Reduces size of struct cmark_node by 8 bytes. --- src/node.h | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) (limited to 'src/node.h') diff --git a/src/node.h b/src/node.h index ee0ff41..6bf6677 100644 --- a/src/node.h +++ b/src/node.h @@ -8,14 +8,10 @@ extern "C" { #include #include +#include "config.h" #include "cmark.h" #include "buffer.h" -typedef struct { - unsigned char *data; - bufsize_t len; -} cmark_literal; - typedef struct { int marker_offset; int padding; @@ -28,7 +24,6 @@ typedef struct { typedef struct { unsigned char *info; - unsigned char *literal; uint8_t fence_length; uint8_t fence_offset; unsigned char fence_char; @@ -57,7 +52,7 @@ enum cmark_node__internal_flags { }; struct cmark_node { - cmark_strbuf content; + cmark_mem *mem; struct cmark_node *next; struct cmark_node *prev; @@ -67,6 +62,9 @@ struct cmark_node { void *user_data; + unsigned char *data; + bufsize_t len; + int start_line; int start_column; int end_line; @@ -76,7 +74,6 @@ struct cmark_node { uint16_t flags; union { - cmark_literal literal; cmark_list list; cmark_code code; cmark_heading heading; @@ -86,9 +83,6 @@ struct cmark_node { } as; }; -static CMARK_INLINE cmark_mem *cmark_node_mem(cmark_node *node) { - return node->content.mem; -} CMARK_EXPORT int cmark_node_check(cmark_node *node, FILE *out); #ifdef __cplusplus -- cgit v1.2.3