mirror of
https://github.com/ruby/ruby.git
synced 2025-09-15 08:33:58 +02:00
use id_table for constant tables
valgrind 3.9.0 on x86-64 reports a minor reduction in memory usage when loading only RubyGems and RDoc by running: ruby -rrdoc -eexit before: HEAP SUMMARY: in use at exit: 2,913,448 bytes in 27,394 blocks total heap usage: 48,362 allocs, 20,968 frees, 9,034,621 bytes alloc after: HEAP SUMMARY: in use at exit: 2,880,056 bytes in 26,712 blocks total heap usage: 47,791 allocs, 21,079 frees, 9,046,507 bytes alloc * class.c (struct clone_const_arg): adjust for id_table (clone_const): ditto (clone_const_i): ditto (rb_mod_init_copy): ditto (rb_singleton_class_clone_and_attach): ditto (rb_include_class_new): ditto (include_modules_at): ditto * constant.h (rb_free_const_table): ditto * gc.c (free_const_entry_i): ditto (rb_free_const_table): ditto (obj_memsize_of): ditto (mark_const_entry_i): ditto (mark_const_tbl): ditto * internal.h (struct rb_classext_struct): ditto * object.c (rb_mod_const_set): resolve class name on assignment * variable.c (const_update): replace with const_tbl_update (const_tbl_update): new function (fc_i): adjust for id_table (find_class_path): ditto (autoload_const_set): st_update => const_tbl_update (rb_const_remove): adjust for id_table (sv_i): ditto (rb_local_constants_i): ditto (rb_local_constants): ditto (rb_mod_const_at): ditto (rb_mod_const_set): ditto (rb_const_lookup): ditto git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53376 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
b7573a0081
commit
1142de8e2a
6 changed files with 119 additions and 111 deletions
8
object.c
8
object.c
|
@ -2180,6 +2180,14 @@ rb_mod_const_set(VALUE mod, VALUE name, VALUE value)
|
|||
ID id = id_for_setter(mod, name, const, wrong_constant_name);
|
||||
if (!id) id = rb_intern_str(name);
|
||||
rb_const_set(mod, id, value);
|
||||
|
||||
/*
|
||||
* Resolve and cache class name immediately to resolve ambiguity
|
||||
* and avoid order-dependency on const_tbl
|
||||
*/
|
||||
if (RB_TYPE_P(value, T_MODULE) || RB_TYPE_P(value, T_CLASS)) {
|
||||
rb_class_name(value);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue