From 75b48c5938f5984dbcf79a579d15c9cbd6447d12 Mon Sep 17 00:00:00 2001 From: Nick Wellnhofer Date: Sat, 18 Jan 2020 23:37:32 +0100 Subject: Use C string instead of chunk for custom block contents Reduces size of struct cmark_node by 8 bytes. --- src/html.c | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) (limited to 'src/html.c') diff --git a/src/html.c b/src/html.c index 85bd704..f7da7c2 100644 --- a/src/html.c +++ b/src/html.c @@ -179,17 +179,16 @@ static int S_render_node(cmark_node *node, cmark_event_type ev_type, cr(html); break; - case CMARK_NODE_CUSTOM_BLOCK: + case CMARK_NODE_CUSTOM_BLOCK: { + unsigned char *block = entering ? node->as.custom.on_enter : + node->as.custom.on_exit; cr(html); - if (entering) { - cmark_strbuf_put(html, node->as.custom.on_enter.data, - node->as.custom.on_enter.len); - } else { - cmark_strbuf_put(html, node->as.custom.on_exit.data, - node->as.custom.on_exit.len); + if (block) { + cmark_strbuf_puts(html, (char *)block); } cr(html); break; + } case CMARK_NODE_THEMATIC_BREAK: cr(html); @@ -250,15 +249,14 @@ static int S_render_node(cmark_node *node, cmark_event_type ev_type, } break; - case CMARK_NODE_CUSTOM_INLINE: - if (entering) { - cmark_strbuf_put(html, node->as.custom.on_enter.data, - node->as.custom.on_enter.len); - } else { - cmark_strbuf_put(html, node->as.custom.on_exit.data, - node->as.custom.on_exit.len); + case CMARK_NODE_CUSTOM_INLINE: { + unsigned char *block = entering ? node->as.custom.on_enter : + node->as.custom.on_exit; + if (block) { + cmark_strbuf_puts(html, (char *)block); } break; + } case CMARK_NODE_STRONG: if (entering) { -- cgit v1.2.3