aboutsummaryrefslogtreecommitdiffstats
path: root/eval.c
diff options
context:
space:
mode:
authorAlan Wu <XrXr@users.noreply.github.com>2020-07-22 17:27:03 -0400
committerAlan Wu <XrXr@users.noreply.github.com>2020-07-22 19:01:28 -0400
commit37e6c83609ac9d4c30ca4660ee16701e53cf82a3 (patch)
treefecc7c2b5606d9e0750898edbb9d38cce9e7dd5b /eval.c
parentfdcbb288ab0faf888ed3412113e0064f3a98e1a5 (diff)
downloadruby-37e6c83609ac9d4c30ca4660ee16701e53cf82a3.tar.gz
Lazily insert origins on prepend to save memory
98286e9850936e27e8ae5e4f20858cc9c13d2dde made it so that `Module#include` allocates an origin iclass on each use. Since `include` is widely used, the extra allocation can contribute significantly to memory usage. Instead of always allocating in anticipation of prepend, this change takes a different approach. The new setup inserts a origin iclass into the super chains of all the children of the module when prepend happens for the first time. rb_ensure_origin is made static again since now that adding an origin now means walking over all usages, we want to limit the number of places where we do it.
Diffstat (limited to 'eval.c')
-rw-r--r--eval.c3
1 files changed, 0 insertions, 3 deletions
diff --git a/eval.c b/eval.c
index 52f3cc4e9f..237d9acaa7 100644
--- a/eval.c
+++ b/eval.c
@@ -1551,9 +1551,6 @@ rb_mod_refine(VALUE module, VALUE klass)
}
ensure_class_or_module(klass);
- if (RB_TYPE_P(klass, T_MODULE)) {
- rb_ensure_origin(klass);
- }
CONST_ID(id_refinements, "__refinements__");
refinements = rb_attr_get(module, id_refinements);
if (NIL_P(refinements)) {