From 3acbdf0965859c55fa36c65a4c0e17e92012687c Mon Sep 17 00:00:00 2001 From: Nick Wellnhofer Date: Sat, 18 Jan 2020 22:27:13 +0100 Subject: Use C string instead of chunk for code info and literal Use zero-terminated C strings instead of cmark_chunks without storing the length. The length of code literals will be readded in a later commit. strlen overhead for code info should be negligible. Reduces size of struct cmark_node by 8 bytes. --- src/html.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'src/html.c') diff --git a/src/html.c b/src/html.c index a13d016..161e9f9 100644 --- a/src/html.c +++ b/src/html.c @@ -146,25 +146,26 @@ static int S_render_node(cmark_node *node, cmark_event_type ev_type, case CMARK_NODE_CODE_BLOCK: cr(html); - if (node->as.code.info.len == 0) { + if (node->as.code.info == NULL || node->as.code.info[0] == 0) { cmark_strbuf_puts(html, ""); } else { bufsize_t first_tag = 0; - while (first_tag < node->as.code.info.len && - !cmark_isspace(node->as.code.info.data[first_tag])) { + while (node->as.code.info[first_tag] && + !cmark_isspace(node->as.code.info[first_tag])) { first_tag += 1; } cmark_strbuf_puts(html, "as.code.info.data, first_tag); + escape_html(html, node->as.code.info, first_tag); cmark_strbuf_puts(html, "\">"); } - escape_html(html, node->as.code.literal.data, node->as.code.literal.len); + escape_html(html, node->as.code.literal, + strlen((char *)node->as.code.literal)); cmark_strbuf_puts(html, "\n"); break; -- cgit v1.2.3