summaryrefslogtreecommitdiff
path: root/parse.y
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-07-20 10:01:05 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-07-20 10:01:05 +0000
commit5a392c71dbf5cdc5af261acd3c56eac39e217988 (patch)
tree669c874771eb57da68840d114b456ce247a81067 /parse.y
parentabc20ed0f4b0067ad912f345245161426d331ed8 (diff)
* compile.c (compile_dstr_fragments): reduced needless literal.
* parse.y (xstring, regexp, dsym, literal_concat, evstr2dstr): literal at the top of dstr is no longer needed if it is empty, since concatstrings and toregexp always create new strings. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24212 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'parse.y')
-rw-r--r--parse.y12
1 files changed, 6 insertions, 6 deletions
diff --git a/parse.y b/parse.y
index 4636b4de30..3e4bc729b2 100644
--- a/parse.y
+++ b/parse.y
@@ -3806,7 +3806,7 @@ xstring : tXSTRING_BEG xstring_contents tSTRING_END
nd_set_type(node, NODE_DXSTR);
break;
default:
- node = NEW_NODE(NODE_DXSTR, STR_NEW0(), 1, NEW_LIST(node));
+ node = NEW_NODE(NODE_DXSTR, Qnil, 1, NEW_LIST(node));
break;
}
}
@@ -3835,7 +3835,7 @@ regexp : tREGEXP_BEG xstring_contents tREGEXP_END
}
break;
default:
- node = NEW_NODE(NODE_DSTR, STR_NEW0(), 1, NEW_LIST(node));
+ node = NEW_NODE(NODE_DSTR, Qnil, 1, NEW_LIST(node));
case NODE_DSTR:
if (options & RE_OPTION_ONCE) {
nd_set_type(node, NODE_DREGX_ONCE);
@@ -3844,7 +3844,7 @@ regexp : tREGEXP_BEG xstring_contents tREGEXP_END
nd_set_type(node, NODE_DREGX);
}
node->nd_cflag = options & RE_OPTION_MASK;
- reg_fragment_check(node->nd_lit, options);
+ if (!NIL_P(node->nd_lit)) reg_fragment_check(node->nd_lit, options);
for (list = node->nd_next; list; list = list->nd_next) {
if (nd_type(list->nd_head) == NODE_STR) {
reg_fragment_check(list->nd_head->nd_lit, options);
@@ -4081,7 +4081,7 @@ dsym : tSYMBEG xstring_contents tSTRING_END
nd_set_type($$, NODE_LIT);
break;
default:
- $$ = NEW_NODE(NODE_DSYM, STR_NEW0(), 1, NEW_LIST($$));
+ $$ = NEW_NODE(NODE_DSYM, Qnil, 1, NEW_LIST($$));
break;
}
}
@@ -7809,7 +7809,7 @@ literal_concat_gen(struct parser_params *parser, NODE *head, NODE *tail)
htype = nd_type(head);
if (htype == NODE_EVSTR) {
- NODE *node = NEW_DSTR(STR_NEW0());
+ NODE *node = NEW_DSTR(Qnil);
head = list_append(node, head);
}
switch (nd_type(tail)) {
@@ -7858,7 +7858,7 @@ static NODE *
evstr2dstr_gen(struct parser_params *parser, NODE *node)
{
if (nd_type(node) == NODE_EVSTR) {
- node = list_append(NEW_DSTR(STR_NEW0()), node);
+ node = list_append(NEW_DSTR(Qnil), node);
}
return node;
}