From dc6d7cc58e78903e8309ff94c9e7112d661646ee Mon Sep 17 00:00:00 2001 From: nobu Date: Sun, 14 May 2017 11:45:00 +0000 Subject: object.c: use a sized enumerator with #yield_self * object.c (rb_obj_size): The #yield_self Enumerator instance always has a #count of `1`. This provides a lazy #size of `1` to match the count instead of `nil`. [Fix GH-1615] Author: Shannon Skipper git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58714 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- object.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'object.c') diff --git a/object.c b/object.c index 6c0aa040b9..15c6f960db 100644 --- a/object.c +++ b/object.c @@ -497,6 +497,12 @@ rb_obj_itself(VALUE obj) return obj; } +static VALUE +rb_obj_size(VALUE self, VALUE args, VALUE obj) +{ + return LONG2FIX(1); +} + /* * call-seq: * obj.yield_self {|_obj|...} -> an_object @@ -510,7 +516,7 @@ rb_obj_itself(VALUE obj) static VALUE rb_obj_yield_self(VALUE obj) { - RETURN_ENUMERATOR(obj, 0, 0); + RETURN_SIZED_ENUMERATOR(obj, 0, 0, rb_obj_size); return rb_yield_values2(1, &obj); } -- cgit v1.2.3