Skip to content
Browse files

* compile.c (when_vals): when a string literal is written on when

  clause, skip string creation to make it faster.  [ruby-dev:44068]
  [Feature #5000]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32484 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information...
1 parent b0f115d commit b88daae7ecd3853f4c56d9bb74e0e06ea2a0a939 @mame mame committed Jul 10, 2011
Showing with 14 additions and 1 deletion.
  1. +6 −0 ChangeLog
  2. +8 −1 compile.c
View
6 ChangeLog
@@ -1,3 +1,9 @@
+Sun Jul 10 12:08:39 2011 Yusuke Endoh <mame@tsg.ne.jp>
+
+ * compile.c (when_vals): when a string literal is written on when
+ clause, skip string creation to make it faster. [ruby-dev:44068]
+ [Feature #5000]
+
Sun Jul 10 11:35:29 2011 Yusuke Endoh <mame@tsg.ne.jp>
* parse.y (reduce_nodes_gen): NODE_RETURN in rescue body must not be
View
9 compile.c
@@ -2362,7 +2362,14 @@ when_vals(rb_iseq_t *iseq, LINK_ANCHOR *cond_seq, NODE *vals, LABEL *l1, VALUE s
special_literals = Qfalse;
}
- COMPILE(cond_seq, "when cond", val);
+ if (nd_type(val) == NODE_STR) {
+ debugp_param("nd_lit", val->nd_lit);
+ OBJ_FREEZE(val->nd_lit);
+ ADD_INSN1(cond_seq, nd_line(val), putobject, val->nd_lit);
+ }
+ else {
+ COMPILE(cond_seq, "when cond", val);
+ }
ADD_INSN1(cond_seq, nd_line(val), topn, INT2FIX(1));
ADD_SEND(cond_seq, nd_line(val), ID2SYM(idEqq), INT2FIX(1));
ADD_INSNL(cond_seq, nd_line(val), branchif, l1);

0 comments on commit b88daae

Please sign in to comment.
Something went wrong with that request. Please try again.