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

Collect symbols instead of strings and get rid of rb_str_intern

This commit is contained in:
Nobuyoshi Nakada 2021-10-07 20:11:48 +09:00
parent 55d7f63bde
commit d0268c5ec2
No known key found for this signature in database
GPG key ID: 7CD2805BFA3770C6

6
vm.c
View file

@ -985,11 +985,11 @@ collect_outer_variable_names(ID id, VALUE val, void *ptr)
if (data->isolate || if (data->isolate ||
val == Qtrue /* write */) { val == Qtrue /* write */) {
if (data->ary == Qfalse) data->ary = rb_ary_new(); if (data->ary == Qfalse) data->ary = rb_ary_new();
rb_ary_push(data->ary, rb_id2str(id)); rb_ary_push(data->ary, ID2SYM(id));
} }
else { else {
if (data->read_only == Qfalse) data->read_only = rb_ary_new(); if (data->read_only == Qfalse) data->read_only = rb_ary_new();
rb_ary_push(data->read_only, rb_id2str(id)); rb_ary_push(data->read_only, ID2SYM(id));
} }
} }
return ID_TABLE_CONTINUE; return ID_TABLE_CONTINUE;
@ -1007,7 +1007,7 @@ env_copy(const VALUE *src_ep, VALUE read_only_variables)
if (read_only_variables) { if (read_only_variables) {
for (int i=RARRAY_LENINT(read_only_variables)-1; i>=0; i--) { for (int i=RARRAY_LENINT(read_only_variables)-1; i>=0; i--) {
ID id = SYM2ID(rb_str_intern(RARRAY_AREF(read_only_variables, i))); ID id = SYM2ID(RARRAY_AREF(read_only_variables, i));
for (unsigned int j=0; j<src_env->iseq->body->local_table_size; j++) { for (unsigned int j=0; j<src_env->iseq->body->local_table_size; j++) {
if (id == src_env->iseq->body->local_table[j]) { if (id == src_env->iseq->body->local_table[j]) {