diff options
author | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2021-09-28 23:25:51 +0900 |
---|---|---|
committer | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2021-10-01 20:28:44 +0900 |
commit | 409dbc951b9875d27bd73748c88e15386473cffb (patch) | |
tree | 74615fa1a38275ea07556b0a2efa59714c46f5c6 | |
parent | b6534691a16d751d59fc572d5dddebcaeb21f007 (diff) | |
download | ruby-409dbc951b9875d27bd73748c88e15386473cffb.tar.gz |
Replace expanded load path only when modified
-rw-r--r-- | ruby.c | 6 |
1 files changed, 5 insertions, 1 deletions
@@ -1931,13 +1931,17 @@ process_options(int argc, char **argv, ruby_cmdline_options_t *opt) } { VALUE loaded_features = vm->loaded_features; + bool modified = false; for (long i = loaded_before_enc; i < RARRAY_LEN(loaded_features); ++i) { VALUE path = RARRAY_AREF(loaded_features, i); if (rb_enc_get(path) == IF_UTF8_PATH(uenc, lenc)) continue; path = copy_str(path, IF_UTF8_PATH(uenc, lenc), true); + modified = true; RARRAY_ASET(loaded_features, i, path); } - rb_get_expanded_load_path(); + if (modified) { + rb_ary_replace(vm->loaded_features_snapshot, loaded_features); + } } if (opt->features.mask & COMPILATION_FEATURES) { |