summaryrefslogtreecommitdiff
path: root/iseq.c
diff options
context:
space:
mode:
authornormal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-01-26 06:23:47 +0000
committernormal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-01-26 06:23:47 +0000
commit1282a4a89500f3c45f0cd56623d536f40abe9bb6 (patch)
tree949c6c2a2ed80f61fc9bc7e6a386fbb915b2cc48 /iseq.c
parentf4ca0739ecf00e9c50aaca55e0ecc5e33dd49284 (diff)
fstring early for internal iseq
All of the strings created here eventually get converted to fstrings when they are frozen into the iseq. Prepare the fstring early so we may reduce a one or two objects. This is a very minor change, mainly for the '<main>' dedupe. * compile.c (caller_location): use rb_fstring_cstr for "<compiled>" (it is converted to fstring anyways inside rb_iseq_new_with_opt) * iseq.c (iseqw_s_compile): ditto * iseq.c (rb_iseq_new_main): use rb_fstring_cstr for "<main>" * vm.c (Init_VM): ditto, share with with above * iseq.c (iseqw_s_compile_file): rb_fstring before rb_io_t->pathv share "<main>" with above * vm.c (rb_binding_add_dynavars): fstring "<temp>" immediately git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53659 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'iseq.c')
-rw-r--r--iseq.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/iseq.c b/iseq.c
index b8ae57b..3d1713c 100644
--- a/iseq.c
+++ b/iseq.c
@@ -442,7 +442,8 @@ rb_iseq_new_main(NODE *node, VALUE path, VALUE absolute_path)
{
rb_thread_t *th = GET_THREAD();
const rb_iseq_t *parent = th->base_block->iseq;
- return rb_iseq_new_with_opt(node, rb_str_new2("<main>"), path, absolute_path, INT2FIX(0),
+ return rb_iseq_new_with_opt(node, rb_fstring_cstr("<main>"),
+ path, absolute_path, INT2FIX(0),
parent, ISEQ_TYPE_MAIN, &COMPILE_OPTION_DEFAULT);
}
@@ -774,7 +775,7 @@ iseqw_s_compile(int argc, VALUE *argv, VALUE self)
rb_secure(1);
rb_scan_args(argc, argv, "14", &src, &file, &path, &line, &opt);
- if (NIL_P(file)) file = rb_str_new2("<compiled>");
+ if (NIL_P(file)) file = rb_fstring_cstr("<compiled>");
if (NIL_P(line)) line = INT2FIX(1);
return iseqw_new(rb_iseq_compile_with_option(src, file, path, line, 0, opt));
@@ -813,6 +814,7 @@ iseqw_s_compile_file(int argc, VALUE *argv, VALUE self)
rb_secure(1);
rb_scan_args(argc, argv, "11", &file, &opt);
FilePathValue(file);
+ file = rb_fstring(file); /* rb_io_t->pathv gets frozen anyways */
fname = StringValueCStr(file);
f = rb_file_open_str(file, "r");
@@ -824,9 +826,10 @@ iseqw_s_compile_file(int argc, VALUE *argv, VALUE self)
make_compile_option(&option, opt);
- return iseqw_new(rb_iseq_new_with_opt(node, rb_str_new2("<main>"), file,
- rb_realpath_internal(Qnil, file, 1), line, NULL,
- ISEQ_TYPE_TOP, &option));
+ return iseqw_new(rb_iseq_new_with_opt(node, rb_fstring_cstr("<main>"),
+ file,
+ rb_realpath_internal(Qnil, file, 1),
+ line, NULL, ISEQ_TYPE_TOP, &option));
}
/*