1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* vm.c: eagerly allocate loading_table. This eliminates the need to

do NULL checks when looking up the `loading_table` hash.
  https://github.com/ruby/ruby/pull/918

* load.c: remove various NULL checks

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50746 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
tenderlove 2015-06-03 07:21:37 +00:00
parent b5cd6ba214
commit b117572863
3 changed files with 54 additions and 54 deletions

View file

@ -1,3 +1,11 @@
Wed Jun 3 16:17:21 2015 Aaron Patterson <tenderlove@ruby-lang.org>
* vm.c: eagerly allocate `loading_table`. This eliminates the need to
do NULL checks when looking up the `loading_table` hash.
https://github.com/ruby/ruby/pull/918
* load.c: remove various NULL checks
Wed Jun 3 11:47:15 2015 Koichi Sasada <ko1@atdot.net> Wed Jun 3 11:47:15 2015 Koichi Sasada <ko1@atdot.net>
* method.h: change fileds order to gather frequent acces fields. * method.h: change fileds order to gather frequent acces fields.

11
load.c
View file

@ -463,7 +463,6 @@ rb_feature_p(const char *feature, const char *ext, int rb, int expanded, const c
} }
loading_tbl = get_loading_table(); loading_tbl = get_loading_table();
if (loading_tbl) {
f = 0; f = 0;
if (!expanded) { if (!expanded) {
struct loaded_feature_searching fs; struct loaded_feature_searching fs;
@ -513,7 +512,6 @@ rb_feature_p(const char *feature, const char *ext, int rb, int expanded, const c
} }
rb_str_resize(bufstr, 0); rb_str_resize(bufstr, 0);
} }
}
return 0; return 0;
} }
@ -716,11 +714,7 @@ load_lock(const char *ftptr)
st_data_t data; st_data_t data;
st_table *loading_tbl = get_loading_table(); st_table *loading_tbl = get_loading_table();
if (!loading_tbl || !st_lookup(loading_tbl, (st_data_t)ftptr, &data)) { if (!st_lookup(loading_tbl, (st_data_t)ftptr, &data)) {
/* loading ruby library should be serialized. */
if (!loading_tbl) {
GET_VM()->loading_table = loading_tbl = st_init_strtable();
}
/* partial state */ /* partial state */
ftptr = ruby_strdup(ftptr); ftptr = ruby_strdup(ftptr);
data = (st_data_t)rb_thread_shield_new(); data = (st_data_t)rb_thread_shield_new();
@ -1090,9 +1084,6 @@ ruby_init_ext(const char *name, void (*init)(void))
if (rb_provided(name)) if (rb_provided(name))
return; return;
if (!loading_tbl) {
GET_VM()->loading_table = loading_tbl = st_init_strtable();
}
st_update(loading_tbl, (st_data_t)name, register_init_ext, (st_data_t)init); st_update(loading_tbl, (st_data_t)name, register_init_ext, (st_data_t)init);
} }

1
vm.c
View file

@ -2859,6 +2859,7 @@ Init_vm_objects(void)
/* initialize mark object array, hash */ /* initialize mark object array, hash */
vm->mark_object_ary = rb_ary_tmp_new(128); vm->mark_object_ary = rb_ary_tmp_new(128);
vm->loading_table = st_init_strtable();
} }
/* top self */ /* top self */