From 9823c46189d7447692ea6c33e07b4cae5fed74f2 Mon Sep 17 00:00:00 2001 From: shirosaki Date: Mon, 5 Nov 2012 15:27:05 +0000 Subject: Cache the expanded load path * load.c (rb_get_expanded_load_path): cache the expanded load path. This saves 4KB of allocation and some stats for every element of the load path (so nearly a MB in my Rails app) on every require. * load.c (rb_construct_expanded_load_path): ensure that $LOAD_PATH entries are frozen strings. The user must mutate $LOAD_PATH itself rather than its individual entries. * vm_core.h (rb_vm_struct): add fields. * vm.c (rb_vm_mark): mark new fields. * ruby.c (process_options): modify $LOAD_PATH directly rather than its elements. Patch by Greg Price. [ruby-core:47970] [Bug #7158] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37481 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- vm.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'vm.c') diff --git a/vm.c b/vm.c index 90ce21d7fc..61640b891d 100644 --- a/vm.c +++ b/vm.c @@ -1512,6 +1512,8 @@ rb_vm_mark(void *ptr) RUBY_MARK_UNLESS_NULL(vm->thgroup_default); RUBY_MARK_UNLESS_NULL(vm->mark_object_ary); RUBY_MARK_UNLESS_NULL(vm->load_path); + RUBY_MARK_UNLESS_NULL(vm->load_path_snapshot); + RUBY_MARK_UNLESS_NULL(vm->expanded_load_path); RUBY_MARK_UNLESS_NULL(vm->loaded_features); RUBY_MARK_UNLESS_NULL(vm->loaded_features_snapshot); RUBY_MARK_UNLESS_NULL(vm->loaded_features_index); -- cgit v1.2.3