mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
reduce calling mrb_str_new_cstr() to avoid strlen(); #301
This commit is contained in:
+6
-4
@@ -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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user