From db19714b17e365d11ceb13e0d16c8cf3c837f38c Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Tue, 27 Dec 2022 01:32:07 +0000 Subject: [PATCH] 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. --- load.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/load.c b/load.c index 282bebdb62..ce52e5ef60 100644 --- a/load.c +++ b/load.c @@ -367,7 +367,7 @@ get_loaded_features_index(rb_vm_t *vm) VALUE entry, as_str; as_str = entry = rb_ary_entry(features, i); StringValue(as_str); - as_str = rb_fstring(rb_str_freeze(as_str)); + as_str = rb_fstring(as_str); if (as_str != entry) rb_ary_store(features, i, as_str); 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, "$LOADED_FEATURES is frozen; cannot append feature"); } - rb_str_freeze(feature); + feature = rb_fstring(feature); get_loaded_features_index(vm); // If loaded_features and loaded_features_snapshot share the same backing // array, pushing into it would cause the whole array to be copied. // To avoid this we first clear 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)); reset_loaded_features_snapshot(vm); }