mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
should be able to create hash with 127+ entries; close #1894
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user