Project

General

Profile

Bug #6142 ยป lazy_zip_to_a.diff

shugo (Shugo Maeda), 03/16/2012 12:03 PM

View differences:

enumerator.c
1428 1428
}
1429 1429

  
1430 1430
static VALUE
1431
lazy_zip_to_a(int argc, VALUE *argv, VALUE obj)
1432
{
1433
    VALUE zip_args = rb_iv_get(obj, "zip_arguments");
1434
    long i;
1435

  
1436
    if (!NIL_P(zip_args)) {
1437
	for (i = 0; i < RARRAY_LEN(zip_args); i++) {
1438
	    rb_check_funcall(RARRAY_PTR(zip_args)[i], id_rewind, 0, 0);
1439
	}
1440
    }
1441
    return rb_call_super(argc, argv);
1442
}
1443

  
1444
static VALUE
1431 1445
lazy_zip(int argc, VALUE *argv, VALUE obj)
1432 1446
{
1433
    VALUE ary;
1447
    VALUE ary, lazy;
1434 1448
    int i;
1435 1449

  
1436 1450
    if (rb_block_given_p()) {
......
1441 1455
	rb_ary_push(ary, rb_funcall(argv[i], id_lazy, 0));
1442 1456
    }
1443 1457

  
1444
    return rb_block_call(rb_cLazy, id_new, 1, &obj, lazy_zip_func, ary);
1458
    lazy = rb_block_call(rb_cLazy, id_new, 1, &obj, lazy_zip_func, ary);
1459
    rb_iv_set(lazy, "zip_arguments", ary);
1460
    rb_define_singleton_method(lazy, "to_a", lazy_zip_to_a, -1);
1461
    rb_define_singleton_method(lazy, "force", lazy_zip_to_a, -1);
1462
    return lazy;
1445 1463
}
1446 1464

  
1447 1465
static VALUE