summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPatrick McDermott <pj@pehjota.net>2017-10-24 21:46:01 (EDT)
committer Patrick McDermott <pj@pehjota.net>2017-10-24 21:46:01 (EDT)
commit19b21f006ffb14b3791d788f57c9fdc90093b183 (patch)
tree68e24f8a7d1f47177a6cca9ceec72d48f6e5d1e8 /src
parent5f76a52e558a8069fe39ed668e96e9e14165dad3 (diff)
downloadmarquee-19b21f006ffb14b3791d788f57c9fdc90093b183.zip
marquee-19b21f006ffb14b3791d788f57c9fdc90093b183.tar.gz
marquee-19b21f006ffb14b3791d788f57c9fdc90093b183.tar.bz2
mq_tree_insert_sibling*(): Append rather than insert sibling
Diffstat (limited to 'src')
-rw-r--r--src/tree.c19
1 files changed, 9 insertions, 10 deletions
diff --git a/src/tree.c b/src/tree.c
index c3e2323..2db3449 100644
--- a/src/tree.c
+++ b/src/tree.c
@@ -156,22 +156,21 @@ mq_tree_insert_sibling_allocated(MqTree *node, MqTree *sibling, gpointer data)
node->root = sibling->root;
node->parent = sibling->parent;
- /* Link to next sibling, if any. */
- if (sibling->next) {
- node->next = sibling->next;
- sibling->next->prev = node;
+ /* Link new node and parent's last child. */
+ node->prev = node->parent->last_child;
+ if (node->prev) {
+ node->prev->next = node;
}
- /* Link to previous sibling. */
- node->prev = sibling;
- sibling->next = node;
+ /* Set parent's new last child. */
+ node->parent->last_child = node;
+
+ node->position = node->parent->position + node->parent->size - 1;
+ update_positions(node, 1);
node->size = 0;
update_sizes(node, 1);
- node->position = sibling->position + sibling->size - 1;
- update_positions(node, 1);
-
node->data = data;
print_tree("Inserted sibling", node);