Skip to content

Commit

Permalink
compile.c (iseq_compile_each): reduce needless rb_str_dup
Browse files Browse the repository at this point in the history
There is no need to dup the fstring unless we want to set the
debug ivar for it.

[ruby-core:72018] <[email protected]>

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53021 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information
normal committed Dec 10, 2015
1 parent 01c4321 commit 7c41f09
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
5 changes: 5 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
Thu Dec 10 11:33:34 2015 Eric Wong <[email protected]>

* compile.c (iseq_compile_each): reduce needless rb_str_dup
[ruby-core:72018] <[email protected]>

Thu Dec 10 09:32:51 2015 Nobuyoshi Nakada <[email protected]>

* lib/mkmf.rb, lib/shellwords.rb: disable frozen-string-literal.
Expand Down
6 changes: 3 additions & 3 deletions compile.c
Original file line number Diff line number Diff line change
Expand Up @@ -5339,16 +5339,16 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node, int poped)
ADD_INSN1(ret, line, putstring, node->nd_lit);
}
else {
VALUE str = rb_str_dup(node->nd_lit);
if (ISEQ_COMPILE_DATA(iseq)->option->debug_frozen_string_literal || RTEST(ruby_debug)) {
VALUE debug_info = rb_ary_new_from_args(2, iseq->body->location.path, INT2FIX(line));
VALUE str = rb_str_dup(node->nd_lit);
rb_ivar_set(str, id_debug_created_info, rb_obj_freeze(debug_info));
ADD_INSN1(ret, line, putobject, rb_obj_freeze(str));
iseq_add_mark_object_compile_time(iseq, str);
}
else {
ADD_INSN1(ret, line, putobject, rb_fstring(str));
ADD_INSN1(ret, line, putobject, node->nd_lit);
}
iseq_add_mark_object_compile_time(iseq, str);
}
}
break;
Expand Down

0 comments on commit 7c41f09

Please sign in to comment.