summaryrefslogtreecommitdiff
path: root/shape.c
diff options
context:
space:
mode:
Diffstat (limited to 'shape.c')
-rw-r--r--shape.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/shape.c b/shape.c
index 8241f67d6a..1158aad52c 100644
--- a/shape.c
+++ b/shape.c
@@ -863,7 +863,13 @@ rb_shape_get_iv_index(rb_shape_t *shape, ID id, attr_index_t *value)
RUBY_ASSERT(rb_shape_id(shape) != OBJ_TOO_COMPLEX_SHAPE_ID);
if (!shape_cache_get_iv_index(shape, id, value)) {
- return shape_get_iv_index(shape, id, value);
+ // If it wasn't in the ancestor cache, then don't do a linear search
+ if (shape->ancestor_index && shape->next_iv_index >= ANCESTOR_CACHE_THRESHOLD) {
+ return false;
+ }
+ else {
+ return shape_get_iv_index(shape, id, value);
+ }
}
return true;