diff options
author | Alan Wu <[email protected]> | 2020-07-22 17:27:03 -0400 |
---|---|---|
committer | Alan Wu <[email protected]> | 2020-07-22 19:01:28 -0400 |
commit | 37e6c83609ac9d4c30ca4660ee16701e53cf82a3 (patch) | |
tree | fecc7c2b5606d9e0750898edbb9d38cce9e7dd5b /internal/class.h | |
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 'internal/class.h')
-rw-r--r-- | internal/class.h | 1 |
1 files changed, 0 insertions, 1 deletions
diff --git a/internal/class.h b/internal/class.h index eb4e7883f6..40938255af 100644 --- a/internal/class.h +++ b/internal/class.h @@ -119,7 +119,6 @@ VALUE rb_singleton_class_clone_and_attach(VALUE obj, VALUE attach); VALUE rb_singleton_class_get(VALUE obj); int rb_class_has_methods(VALUE c); void rb_undef_methods_from(VALUE klass, VALUE super); -void rb_ensure_origin(VALUE klass); static inline void RCLASS_SET_ORIGIN(VALUE klass, VALUE origin); static inline void RICLASS_SET_ORIGIN_SHARED_MTBL(VALUE iclass); |