Make Array#__combination_next return an array of elements

Since the main processing will be completed on the C side, the Ruby side will simply call the block.
This commit is contained in:
dearblue
2026-04-08 21:25:09 +09:00
parent 5d5cf0c3ea
commit d246ac6c8a
2 changed files with 4 additions and 10 deletions
+3 -2
View File
@@ -1608,10 +1608,11 @@ ary_combination_next(mrb_state *mrb, mrb_value self)
}
}
/* Build current combination indices */
/* Build current combination */
mrb_value result = mrb_ary_new_capa(mrb, state->n);
const mrb_value *p = RARRAY_PTR(self);
for (mrb_int i = 0; i < state->n; i++) {
mrb_ary_push(mrb, result, mrb_fixnum_value(state->indices[i]));
mrb_ary_push(mrb, result, p[state->indices[i]]);
}
mrb_int pos = state->n - 1;