summaryrefslogtreecommitdiff
path: root/iseq.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-10-13 09:59:22 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-10-13 09:59:22 +0000
commitfa8b08b4248d66a172369f4654fec9bdba8c748f (patch)
treeb1217f07f36c92fca08b5f5ee720dc5596de17ff /iseq.c
parent83a01e6f529b80a876508b9501b64e8f1f1414da (diff)
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
Diffstat (limited to 'iseq.c')
-rw-r--r--iseq.c12
1 files changed, 6 insertions, 6 deletions
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("<main>"),
+ return rb_iseq_new_with_opt(ast, rb_fstring_lit("<main>"),
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("<compiled>");
+ rb_fstring_lit("<compiled>");
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("<compiled>");
+ if (NIL_P(file)) file = rb_fstring_lit("<compiled>");
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("<main>"),
+ ret = iseqw_new(rb_iseq_new_with_opt(&ast->body, rb_fstring_lit("<main>"),
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;