reduce calling mrb_str_new_cstr() to avoid strlen(); #301

This commit is contained in:
Yukihiro Matsumoto
2012-06-23 13:51:50 +09:00
parent 1fa63930fd
commit f045e64675
11 changed files with 62 additions and 49 deletions
+6 -4
View File
@@ -1534,10 +1534,11 @@ codegen(codegen_scope *s, node *tree, int val)
case NODE_BACK_REF:
{
char buf[4];
int len;
int sym;
snprintf(buf, 3, "$%c", (int)(intptr_t)tree);
sym = new_sym(s, mrb_intern(s->mrb, buf));
len = snprintf(buf, 3, "$%c", (int)(intptr_t)tree);
sym = new_sym(s, mrb_intern2(s->mrb, buf, len));
genop(s, MKOP_ABx(OP_GETGLOBAL, cursp(), sym));
push();
}
@@ -1546,10 +1547,11 @@ codegen(codegen_scope *s, node *tree, int val)
case NODE_NTH_REF:
{
char buf[4];
int len;
int sym;
snprintf(buf, 3, "$%d", (int)(intptr_t)tree);
sym = new_sym(s, mrb_intern(s->mrb, buf));
len = snprintf(buf, 3, "$%d", (int)(intptr_t)tree);
sym = new_sym(s, mrb_intern2(s->mrb, buf, len));
genop(s, MKOP_ABx(OP_GETGLOBAL, cursp(), sym));
push();
}