summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2014-11-05 13:18:58 -0800
committerJohn MacFarlane <jgm@berkeley.edu>2014-11-05 13:22:21 -0800
commitb56b8cbe99222ce5e1ab0d144a95cb697b93761d (patch)
tree819a5b357139671b5b50313f444ad79d4bf552a7 /src
parentca1e1cde8693b16907efe19b2b9ea9d61dbf3129 (diff)
Made block-freeing slightly more efficient by using last_child.
Diffstat (limited to 'src')
-rw-r--r--src/blocks.c10
1 files changed, 2 insertions, 8 deletions
diff --git a/src/blocks.c b/src/blocks.c
index e8c9e94..d925ced 100644
--- a/src/blocks.c
+++ b/src/blocks.c
@@ -257,7 +257,6 @@ static node_block* add_child(node_block* parent,
void cmark_free_nodes(node_block *e)
{
node_block * next;
- node_block * tmp;
while (e != NULL) {
free_inlines(e->inline_content);
strbuf_free(&e->string_content);
@@ -266,14 +265,9 @@ void cmark_free_nodes(node_block *e)
} else if (e->tag == BLOCK_DOCUMENT) {
reference_map_free(e->as.document.refmap);
}
- tmp = e->children;
- if (tmp) {
- // Find last child
- while (tmp->next) {
- tmp = tmp->next;
- }
+ if (e->last_child) {
// Splice children into list
- tmp->next = e->next;
+ e->last_child->next = e->next;
e->next = e->children;
}
next = e->next;