golf down ancestor caching

This commit is contained in:
Aaron Patterson 2023-10-24 11:59:48 -07:00 committed by Aaron Patterson
parent ee8299864f
commit 702b8e3107

13
shape.c
View File

@ -384,15 +384,7 @@ rb_shape_alloc(ID edge_name, rb_shape_t * parent, enum shape_type type)
static redblack_node_t *
redblack_cache_ancestors(rb_shape_t * shape)
{
if (shape->ancestor_index) {
return shape->ancestor_index;
}
else {
if (shape->parent_id == INVALID_SHAPE_ID) {
// We're at the root
return shape->ancestor_index;
}
else {
if (!(shape->ancestor_index || shape->parent_id == INVALID_SHAPE_ID)) {
redblack_node_t * parent_index;
parent_index = redblack_cache_ancestors(rb_shape_get_parent(shape));
@ -403,10 +395,9 @@ redblack_cache_ancestors(rb_shape_t * shape)
else {
shape->ancestor_index = parent_index;
}
}
return shape->ancestor_index;
}
}
}
#else
static redblack_node_t *