summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-03-08 15:35:05 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-03-08 15:35:05 +0000
commite7d4e659a070f6e188f3924bd8efb65e6919d2ef (patch)
tree2551d574c9e898b8bf837648e136f4e152c17b27
parent0b2c4f43d27510cd0f51a260b5b21fc7e39a5e85 (diff)
* enumerator.c (lazy_initialize, enumerable_lazy): no additional
arguments. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34952 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog5
-rw-r--r--enumerator.c31
2 files changed, 14 insertions, 22 deletions
diff --git a/ChangeLog b/ChangeLog
index 6cd8875174..08f1a9dfc9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Fri Mar 9 00:35:03 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * enumerator.c (lazy_initialize, enumerable_lazy): no additional
+ arguments.
+
Fri Mar 9 00:30:23 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>
* enumerator.c: add Enumerable#lazy. based on the patch by
diff --git a/enumerator.c b/enumerator.c
index ab831499a9..c1a553a705 100644
--- a/enumerator.c
+++ b/enumerator.c
@@ -1231,20 +1231,17 @@ lazy_init_block(VALUE val, VALUE m, int argc, VALUE *argv)
}
static VALUE
-lazy_initialize(int argc, VALUE *argv, VALUE obj)
+lazy_initialize(VALUE self, VALUE obj)
{
- VALUE generator, arg;
+ VALUE generator;
- if (argc < 1) rb_raise(rb_eArgError, "wrong number of arguments(%d for 1+)", argc);
- --argc;
- arg = *argv++;
generator = generator_allocate(rb_cGenerator);
rb_block_call(generator, id_initialize, 0, 0,
(rb_block_given_p() ? lazy_init_block_i: lazy_init_block),
- arg);
- enumerator_init(obj, generator, sym_each, argc, argv);
+ obj);
+ enumerator_init(self, generator, sym_each, 0, 0);
- return obj;
+ return self;
}
/*
@@ -1252,19 +1249,9 @@ lazy_initialize(int argc, VALUE *argv, VALUE obj)
* e.lazy -> lazy_enumerator
*/
static VALUE
-enumerable_lazy(int argc, VALUE *argv, VALUE obj)
+enumerable_lazy(VALUE obj)
{
- if (argc > 0) {
- VALUE ret, buff, *args = ALLOCV_N(VALUE, buff, argc + 1);
- args[0] = obj;
- MEMCPY(args + 1, argv, VALUE, argc);
- ret = rb_class_new_instance(argc + 1, args, rb_cLazy);
- ALLOCV_END(buff);
- return ret;
- }
- else {
- return rb_class_new_instance(1, &obj, rb_cLazy);
- }
+ return rb_class_new_instance(1, &obj, rb_cLazy);
}
static VALUE
@@ -1387,8 +1374,8 @@ Init_Enumerator(void)
/* Enumerable::Lazy */
rb_cLazy = rb_define_class_under(rb_mEnumerable, "Lazy", rb_cEnumerator);
- rb_define_method(rb_mEnumerable, "lazy", enumerable_lazy, -1);
- rb_define_method(rb_cLazy, "initialize", lazy_initialize, -1);
+ rb_define_method(rb_mEnumerable, "lazy", enumerable_lazy, 0);
+ rb_define_method(rb_cLazy, "initialize", lazy_initialize, 1);
rb_define_method(rb_cLazy, "map", lazy_map, 0);
rb_define_method(rb_cLazy, "select", lazy_select, 0);
rb_define_method(rb_cLazy, "reject", lazy_reject, 0);