зеркало из https://github.com/github/ruby.git
Copy path strings as interned strings
This commit is contained in:
Родитель
60d0421ca8
Коммит
b6534691a1
12
ruby.c
12
ruby.c
|
@ -1677,6 +1677,13 @@ tty_enabled(void)
|
||||||
# define tty_enabled() 0
|
# define tty_enabled() 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
static VALUE
|
||||||
|
copy_str(VALUE str, rb_encoding *enc, bool intern)
|
||||||
|
{
|
||||||
|
if (!intern) return rb_enc_associate(rb_str_dup(str), enc);
|
||||||
|
return rb_enc_interned_str(RSTRING_PTR(str), RSTRING_LEN(str), enc);
|
||||||
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
process_options(int argc, char **argv, ruby_cmdline_options_t *opt)
|
process_options(int argc, char **argv, ruby_cmdline_options_t *opt)
|
||||||
{
|
{
|
||||||
|
@ -1909,7 +1916,7 @@ process_options(int argc, char **argv, ruby_cmdline_options_t *opt)
|
||||||
if (newpath == path) continue;
|
if (newpath == path) continue;
|
||||||
path = newpath;
|
path = newpath;
|
||||||
#else
|
#else
|
||||||
path = rb_enc_associate(rb_str_dup(path), lenc);
|
path = copy_str(path, lenc, !mark);
|
||||||
#endif
|
#endif
|
||||||
if (mark) rb_ivar_set(path, id_initial_load_path_mark, path);
|
if (mark) rb_ivar_set(path, id_initial_load_path_mark, path);
|
||||||
if (!modifiable) {
|
if (!modifiable) {
|
||||||
|
@ -1926,7 +1933,8 @@ process_options(int argc, char **argv, ruby_cmdline_options_t *opt)
|
||||||
VALUE loaded_features = vm->loaded_features;
|
VALUE loaded_features = vm->loaded_features;
|
||||||
for (long i = loaded_before_enc; i < RARRAY_LEN(loaded_features); ++i) {
|
for (long i = loaded_before_enc; i < RARRAY_LEN(loaded_features); ++i) {
|
||||||
VALUE path = RARRAY_AREF(loaded_features, i);
|
VALUE path = RARRAY_AREF(loaded_features, i);
|
||||||
path = rb_enc_associate(rb_str_dup(path), IF_UTF8_PATH(uenc, lenc));
|
if (rb_enc_get(path) == IF_UTF8_PATH(uenc, lenc)) continue;
|
||||||
|
path = copy_str(path, IF_UTF8_PATH(uenc, lenc), true);
|
||||||
RARRAY_ASET(loaded_features, i, path);
|
RARRAY_ASET(loaded_features, i, path);
|
||||||
}
|
}
|
||||||
rb_get_expanded_load_path();
|
rb_get_expanded_load_path();
|
||||||
|
|
Загрузка…
Ссылка в новой задаче