Clean duplicate code
Removed duplicates in the code entered for "Concatenate string literal".
@@ -913,11 +913,12 @@ concat_string(parser_state *p, node *a, node *b)
}
}
}
- else if (string_node_p(b)) {
- /* a == NODE_DSTR && b == NODE_STR */
-
- node *c;
+ else {
+ node *c; /* last node of a */
for (c = a; c->cdr != NULL; c = c->cdr) ;
+
+ if (string_node_p(b)) {
+ /* a == NODE_DSTR && b == NODE_STR */
if (string_node_p(c->car)) {
/* a->[..., NODE_STR] && b == NODE_STR */
composite_string_node(p, c->car->cdr, b->cdr);
@@ -930,12 +931,9 @@ concat_string(parser_state *p, node *a, node *b)
}
else {
/* a == NODE_DSTR && b == NODE_DSTR */
-
- node *c, *d;
- for (c = a; c->cdr != NULL; c = c->cdr) ;
if (string_node_p(c->car) && string_node_p(b->cdr->car)) {
/* a->[..., NODE_STR] && b->[NODE_STR, ...] */
- d = b->cdr;
+ node *d = b->cdr;
cons_free(b);
composite_string_node(p, c->car->cdr, d->car->cdr);
cons_free(d->car);
@@ -949,6 +947,7 @@ concat_string(parser_state *p, node *a, node *b)
return a;
}
}
+ }
return new_dstr(p, list2(a, b));
}
