diff options
author | Alan Wu <XrXr@users.noreply.github.com> | 2020-07-22 17:27:03 -0400 |
---|---|---|
committer | Alan Wu <XrXr@users.noreply.github.com> | 2020-07-22 19:01:28 -0400 |
commit | 37e6c83609ac9d4c30ca4660ee16701e53cf82a3 (patch) | |
tree | fecc7c2b5606d9e0750898edbb9d38cce9e7dd5b /eval.c | |
parent | fdcbb288ab0faf888ed3412113e0064f3a98e1a5 (diff) |
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.
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/3331
Diffstat (limited to 'eval.c')
-rw-r--r-- | eval.c | 3 |
1 files changed, 0 insertions, 3 deletions
@@ -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)) { |