From fa8b08b4248d66a172369f4654fec9bdba8c748f Mon Sep 17 00:00:00 2001 From: nobu Date: Sat, 13 Oct 2018 09:59:22 +0000 Subject: Prefer `rb_fstring_lit` over `rb_fstring_cstr` The former states explicitly that the argument must be a literal, and can optimize away `strlen` on all compilers. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65059 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- iseq.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'iseq.c') diff --git a/iseq.c b/iseq.c index 831a9e8109..343fc9e5b8 100644 --- a/iseq.c +++ b/iseq.c @@ -668,7 +668,7 @@ rb_iseq_new_top(const rb_ast_body_t *ast, VALUE name, VALUE path, VALUE realpath rb_iseq_t * rb_iseq_new_main(const rb_ast_body_t *ast, VALUE path, VALUE realpath, const rb_iseq_t *parent) { - return rb_iseq_new_with_opt(ast, rb_fstring_cstr("
"), + return rb_iseq_new_with_opt(ast, rb_fstring_lit("
"), path, realpath, INT2FIX(0), parent, ISEQ_TYPE_MAIN, &COMPILE_OPTION_DEFAULT); } @@ -894,7 +894,7 @@ rb_iseq_compile_with_option(VALUE src, VALUE file, VALUE realpath, VALUE line, c else { INITIALIZED VALUE label = parent ? parent->body->location.label : - rb_fstring_cstr(""); + rb_fstring_lit(""); iseq = rb_iseq_new_with_opt(&ast->body, label, file, realpath, line, parent, type, &option); rb_ast_dispose(ast); @@ -1076,7 +1076,7 @@ iseqw_s_compile(int argc, VALUE *argv, VALUE self) case 2: file = argv[--i]; } - if (NIL_P(file)) file = rb_fstring_cstr(""); + if (NIL_P(file)) file = rb_fstring_lit(""); if (NIL_P(path)) path = file; if (NIL_P(line)) line = INT2FIX(1); @@ -1139,7 +1139,7 @@ iseqw_s_compile_file(int argc, VALUE *argv, VALUE self) make_compile_option(&option, opt); - ret = iseqw_new(rb_iseq_new_with_opt(&ast->body, rb_fstring_cstr("
"), + ret = iseqw_new(rb_iseq_new_with_opt(&ast->body, rb_fstring_lit("
"), file, rb_realpath_internal(Qnil, file, 1), line, NULL, ISEQ_TYPE_TOP, &option)); @@ -1702,10 +1702,10 @@ rb_insn_operand_intern(const rb_iseq_t *iseq, if (insn == BIN(defined) && op_no == 0) { enum defined_type deftype = (enum defined_type)op; if (deftype == DEFINED_FUNC) { - ret = rb_fstring_cstr("func"); break; + ret = rb_fstring_lit("func"); break; } if (deftype == DEFINED_REF) { - ret = rb_fstring_cstr("ref"); break; + ret = rb_fstring_lit("ref"); break; } ret = rb_iseq_defined_string(deftype); if (ret) break; -- cgit v1.2.3