summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--include/mruby/string.h4
-rw-r--r--src/codegen.c17
-rw-r--r--src/string.c3
3 files changed, 15 insertions, 9 deletions
diff --git a/include/mruby/string.h b/include/mruby/string.h
index 3f661a742..4ba4ce544 100644
--- a/include/mruby/string.h
+++ b/include/mruby/string.h
@@ -11,10 +11,6 @@
extern "C" {
#endif
-#ifndef RB_GC_GUARD
-#define RB_GC_GUARD(v) v
-#endif
-
#define IS_EVSTR(p,e) ((p) < (e) && (*(p) == '$' || *(p) == '@' || *(p) == '{'))
#define STR_BUF_MIN_SIZE 128
diff --git a/src/codegen.c b/src/codegen.c
index 6f564586c..33df7fbf5 100644
--- a/src/codegen.c
+++ b/src/codegen.c
@@ -336,6 +336,17 @@ genop_peep(codegen_scope *s, mrb_code i, int val)
s->iseq[s->pc-1] = MKOP_ABC(OP_SUBI, GETARG_A(i), GETARG_B(i), -c);
return;
}
+ case OP_STRCAT:
+ if (c0 == OP_STRING) {
+ int i = GETARG_Bx(i0);
+
+ if (mrb_type(s->irep->pool[i]) == MRB_TT_STRING &&
+ RSTRING_LEN(s->irep->pool[i]) == 0) {
+ s->pc--;
+ return;
+ }
+ }
+ break;
default:
break;
}
@@ -1934,7 +1945,7 @@ codegen(codegen_scope *s, node *tree, int val)
while (n) {
codegen(s, n->car, VAL);
pop(); pop();
- genop(s, MKOP_AB(OP_STRCAT, cursp(), cursp()+1));
+ genop_peep(s, MKOP_AB(OP_STRCAT, cursp(), cursp()+1), VAL);
push();
n = n->cdr;
}
@@ -1996,7 +2007,7 @@ codegen(codegen_scope *s, node *tree, int val)
while (n) {
codegen(s, n->car, VAL);
pop(); pop();
- genop(s, MKOP_AB(OP_STRCAT, cursp(), cursp()+1));
+ genop_peep(s, MKOP_AB(OP_STRCAT, cursp(), cursp()+1), VAL);
push();
n = n->cdr;
}
@@ -2007,7 +2018,7 @@ codegen(codegen_scope *s, node *tree, int val)
codegen(s, tree->car, VAL);
genop(s, MKOP_ABx(OP_STRING, cursp(), off));
pop();
- genop(s, MKOP_AB(OP_STRCAT, cursp(), cursp()+1));
+ genop_peep(s, MKOP_AB(OP_STRCAT, cursp(), cursp()+1), VAL);
}
if (n->cdr) {
char *p2 = (char*)n->cdr;
diff --git a/src/string.c b/src/string.c
index 53e8fcab6..679b06f9e 100644
--- a/src/string.c
+++ b/src/string.c
@@ -1511,9 +1511,8 @@ mrb_value
mrb_str_intern(mrb_state *mrb, mrb_value self)
{
mrb_sym id;
- mrb_value str = RB_GC_GUARD(self);
- id = mrb_intern_str(mrb, str);
+ id = mrb_intern_str(mrb, self);
return mrb_symbol_value(id);
}