summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--shape.c7
-rw-r--r--test/ruby/test_object.rb2
2 files changed, 5 insertions, 4 deletions
diff --git a/shape.c b/shape.c
index 2d5c2109c7..c78a02a1cb 100644
--- a/shape.c
+++ b/shape.c
@@ -733,9 +733,10 @@ rb_shape_get_next(rb_shape_t *shape, VALUE obj, ID id)
if (RCLASS_EXT(klass)->variation_count >= SHAPE_MAX_VARIATIONS) {
rb_category_warn(
RB_WARN_CATEGORY_PERFORMANCE,
- "Maximum shapes variations (%d) reached by %"PRIsVALUE", instance variables accesses will be slower.",
- SHAPE_MAX_VARIATIONS,
- rb_class_path(klass)
+ "The class %"PRIsVALUE" reached %d shape variations, instance variables accesses will be slower and memory usage increased.\n"
+ "It is recommended to define instance variable in a consistent order, for instance by eagerly defining them all in the `initialize` method.",
+ rb_class_path(klass),
+ SHAPE_MAX_VARIATIONS
);
}
}
diff --git a/test/ruby/test_object.rb b/test/ruby/test_object.rb
index acc913b9c0..0bb9e633a1 100644
--- a/test/ruby/test_object.rb
+++ b/test/ruby/test_object.rb
@@ -458,7 +458,7 @@ class TestObject < Test::Unit::TestCase
end
def test_max_shape_variation_with_performance_warnings
- assert_in_out_err([], <<-INPUT, %w(), /Maximum shapes variations \(8\) reached by Foo, instance variables accesses will be slower\.$/)
+ assert_in_out_err([], <<-INPUT, %w(), /The class Foo reached 8 shape variations, instance variables accesses will be slower and memory usage increased/)
$VERBOSE = false
Warning[:performance] = true