From ceb375484eb03a6b4fd23b6c6fa84c3c06da89bf Mon Sep 17 00:00:00 2001 From: normal Date: Tue, 26 Jan 2016 06:23:47 +0000 Subject: 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 '
' dedupe. * compile.c (caller_location): use rb_fstring_cstr for "" (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 "
" * vm.c (Init_VM): ditto, share with with above * iseq.c (iseqw_s_compile_file): rb_fstring before rb_io_t->pathv share "
" with above * vm.c (rb_binding_add_dynavars): fstring "" immediately git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53659 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- iseq.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'iseq.c') diff --git a/iseq.c b/iseq.c index b8ae57b782..3d1713c6be 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("
"), path, absolute_path, INT2FIX(0), + return rb_iseq_new_with_opt(node, rb_fstring_cstr("
"), + 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(""); + if (NIL_P(file)) file = rb_fstring_cstr(""); 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("
"), 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("
"), + file, + rb_realpath_internal(Qnil, file, 1), + line, NULL, ISEQ_TYPE_TOP, &option)); } /* -- cgit v1.2.3