summaryrefslogtreecommitdiff
path: root/src/html.c
diff options
context:
space:
mode:
authorNick Wellnhofer <wellnhofer@aevum.de>2020-01-18 23:37:32 +0100
committerJohn MacFarlane <jgm@berkeley.edu>2020-01-23 08:25:54 -0800
commit75b48c5938f5984dbcf79a579d15c9cbd6447d12 (patch)
tree7c97c1d4fbcb6b7230e1d4893a2c3eff766fe0bc /src/html.c
parentb237924585e61532ada774bf9e70eadff00666dc (diff)
Use C string instead of chunk for custom block contents
Reduces size of struct cmark_node by 8 bytes.
Diffstat (limited to 'src/html.c')
-rw-r--r--src/html.c26
1 files changed, 12 insertions, 14 deletions
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) {