load.c: remove unneeded rb_str_freeze calls

rb_fstring already resizes and freezes the string, so there's no
need to use rb_str_freeze.
This commit is contained in:
Eric Wong 2022-12-27 01:32:07 +00:00
parent c09f342d04
commit db19714b17

6
load.c
View File

@ -367,7 +367,7 @@ get_loaded_features_index(rb_vm_t *vm)
VALUE entry, as_str; VALUE entry, as_str;
as_str = entry = rb_ary_entry(features, i); as_str = entry = rb_ary_entry(features, i);
StringValue(as_str); StringValue(as_str);
as_str = rb_fstring(rb_str_freeze(as_str)); as_str = rb_fstring(as_str);
if (as_str != entry) if (as_str != entry)
rb_ary_store(features, i, as_str); rb_ary_store(features, i, as_str);
features_index_add(vm, as_str, INT2FIX(i)); features_index_add(vm, as_str, INT2FIX(i));
@ -655,14 +655,14 @@ rb_provide_feature(rb_vm_t *vm, VALUE feature)
rb_raise(rb_eRuntimeError, rb_raise(rb_eRuntimeError,
"$LOADED_FEATURES is frozen; cannot append feature"); "$LOADED_FEATURES is frozen; cannot append feature");
} }
rb_str_freeze(feature); feature = rb_fstring(feature);
get_loaded_features_index(vm); get_loaded_features_index(vm);
// If loaded_features and loaded_features_snapshot share the same backing // If loaded_features and loaded_features_snapshot share the same backing
// array, pushing into it would cause the whole array to be copied. // array, pushing into it would cause the whole array to be copied.
// To avoid this we first clear loaded_features_snapshot. // To avoid this we first clear loaded_features_snapshot.
rb_ary_clear(vm->loaded_features_snapshot); rb_ary_clear(vm->loaded_features_snapshot);
rb_ary_push(features, rb_fstring(feature)); rb_ary_push(features, feature);
features_index_add(vm, feature, INT2FIX(RARRAY_LEN(features)-1)); features_index_add(vm, feature, INT2FIX(RARRAY_LEN(features)-1));
reset_loaded_features_snapshot(vm); reset_loaded_features_snapshot(vm);
} }