From f045e646751bfe0f399aae59746befa6384b96aa Mon Sep 17 00:00:00 2001 From: Yukihiro Matsumoto Date: Sat, 23 Jun 2012 13:51:50 +0900 Subject: reduce calling mrb_str_new_cstr() to avoid strlen(); #301 --- src/codegen.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src/codegen.c') diff --git a/src/codegen.c b/src/codegen.c index 72fc1097d..cbf401a1f 100644 --- a/src/codegen.c +++ b/src/codegen.c @@ -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(); } -- cgit v1.2.3