summaryrefslogtreecommitdiff
path: root/src/node.h
diff options
context:
space:
mode:
authorNick Wellnhofer <wellnhofer@aevum.de>2020-01-19 13:46:10 +0100
committerJohn MacFarlane <jgm@berkeley.edu>2020-01-23 08:25:54 -0800
commitf3f50b29d615d2678d8047dc277b108cc5143167 (patch)
treeca3f01f6352d2cc2dd7cfc9c96508b800b8cc510 /src/node.h
parent3ef0718f9f4c9dea5014a8a0e9a67e2366b9374f (diff)
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.
Diffstat (limited to 'src/node.h')
-rw-r--r--src/node.h16
1 files changed, 5 insertions, 11 deletions
diff --git a/src/node.h b/src/node.h
index ee0ff41..6bf6677 100644
--- a/src/node.h
+++ b/src/node.h
@@ -8,15 +8,11 @@ extern "C" {
#include <stdio.h>
#include <stdint.h>
+#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;
int start;
@@ -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