summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--shape.c29
1 files changed, 10 insertions, 19 deletions
diff --git a/shape.c b/shape.c
index 69776c25f3..a8c9d8337c 100644
--- a/shape.c
+++ b/shape.c
@@ -384,29 +384,20 @@ 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 {
- redblack_node_t * parent_index;
+ 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));
+ parent_index = redblack_cache_ancestors(rb_shape_get_parent(shape));
- if (shape->type == SHAPE_IVAR) {
- shape->ancestor_index = redblack_insert(parent_index, shape->edge_name, shape);
- }
- else {
- shape->ancestor_index = parent_index;
- }
-
- return shape->ancestor_index;
+ if (shape->type == SHAPE_IVAR) {
+ shape->ancestor_index = redblack_insert(parent_index, shape->edge_name, shape);
+ }
+ else {
+ shape->ancestor_index = parent_index;
}
}
+
+ return shape->ancestor_index;
}
#else
static redblack_node_t *