From 45b0e1f788e9085be5039bb4b83aa4bbfaa2d1ca Mon Sep 17 00:00:00 2001 From: "Yukihiro \"Matz\" Matsumoto" Date: Fri, 21 Mar 2014 09:18:10 +0900 Subject: should be able to create hash with 127+ entries; close #1894 --- src/codegen.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src/codegen.c') diff --git a/src/codegen.c b/src/codegen.c index 317ce6232..9b14d1530 100644 --- a/src/codegen.c +++ b/src/codegen.c @@ -1501,16 +1501,32 @@ codegen(codegen_scope *s, node *tree, int val) case NODE_HASH: { int len = 0; + mrb_bool update = FALSE; while (tree) { codegen(s, tree->car->car, val); codegen(s, tree->car->cdr, val); len++; tree = tree->cdr; + if (val && len == 126) { + pop_n(len*2); + genop(s, MKOP_ABC(OP_HASH, cursp(), cursp(), len)); + if (update) { + pop(); + genop(s, MKOP_ABC(OP_SEND, cursp(), new_msym(s, mrb_intern_lit(s->mrb, "merge")), 1)); + } + push(); + update = TRUE; + len = 0; + } } if (val) { pop_n(len*2); genop(s, MKOP_ABC(OP_HASH, cursp(), cursp(), len)); + if (update) { + pop(); + genop(s, MKOP_ABC(OP_SEND, cursp(), new_msym(s, mrb_intern_lit(s->mrb, "merge")), 1)); + } push(); } } -- cgit v1.2.3