diff options
| author | Yukihiro Matsumoto <[email protected]> | 2012-06-23 13:51:50 +0900 |
|---|---|---|
| committer | Yukihiro Matsumoto <[email protected]> | 2012-06-23 13:51:50 +0900 |
| commit | f045e646751bfe0f399aae59746befa6384b96aa (patch) | |
| tree | f14b8e5b4525fbba488a7e1120a61d48b155da2d /src/codegen.c | |
| parent | 1fa63930fd072847d24ffe9c20a57109c41387ec (diff) | |
| download | mruby-f045e646751bfe0f399aae59746befa6384b96aa.tar.gz mruby-f045e646751bfe0f399aae59746befa6384b96aa.zip | |
reduce calling mrb_str_new_cstr() to avoid strlen(); #301
Diffstat (limited to 'src/codegen.c')
| -rw-r--r-- | src/codegen.c | 10 |
1 files changed, 6 insertions, 4 deletions
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(); } |
