From cfd7c1a2763d727f8a578da27317b55111aa6894 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Tue, 24 Oct 2023 12:20:46 -0700 Subject: Allow the shape tree to be traversed This commit allows the shape tree to be traversed to locate an existing shape, but it doesn't necessarily allow you to create new variations. --- shape.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'shape.c') diff --git a/shape.c b/shape.c index 27009f24ab..85df16249e 100644 --- a/shape.c +++ b/shape.c @@ -435,7 +435,7 @@ rb_shape_alloc_new_child(ID id, rb_shape_t * shape, enum shape_type shape_type) } static rb_shape_t* -get_next_shape_internal(rb_shape_t * shape, ID id, enum shape_type shape_type, bool * variation_created, bool new_shapes_allowed) +get_next_shape_internal(rb_shape_t * shape, ID id, enum shape_type shape_type, bool * variation_created, bool new_variations_allowed) { rb_shape_t *res = NULL; @@ -444,7 +444,7 @@ get_next_shape_internal(rb_shape_t * shape, ID id, enum shape_type shape_type, b *variation_created = false; - if ((new_shapes_allowed && (GET_SHAPE_TREE()->next_shape_id <= MAX_SHAPE_ID))) { + if (GET_SHAPE_TREE()->next_shape_id <= MAX_SHAPE_ID) { RB_VM_LOCK_ENTER(); { // If the current shape has children @@ -478,10 +478,12 @@ get_next_shape_internal(rb_shape_t * shape, ID id, enum shape_type shape_type, b // we know we need a new child shape, and that we must insert // it in to the table. if (!res) { - *variation_created = true; - rb_shape_t * new_shape = rb_shape_alloc_new_child(id, shape, shape_type); - rb_id_table_insert(shape->edges, id, (VALUE)new_shape); - res = new_shape; + if (new_variations_allowed) { + *variation_created = true; + rb_shape_t * new_shape = rb_shape_alloc_new_child(id, shape, shape_type); + rb_id_table_insert(shape->edges, id, (VALUE)new_shape); + res = new_shape; + } } } else { -- cgit v1.2.3