зеркало из https://github.com/github/ruby.git
* struct.c (rb_struct_each_pair): use rb_yield_values(2, key, value)
instead of rb_yield(rb_assoc_new(key, value)) if rb_block_arity() is greater than 1. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41986 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
1a42f3683f
Коммит
d738fed4eb
|
@ -1,3 +1,9 @@
|
|||
Mon Jul 15 14:13:02 2013 Masaki Matsushita <glass.saga@gmail.com>
|
||||
|
||||
* struct.c (rb_struct_each_pair): use rb_yield_values(2, key, value)
|
||||
instead of rb_yield(rb_assoc_new(key, value)) if rb_block_arity()
|
||||
is greater than 1.
|
||||
|
||||
Mon Jul 15 13:46:26 2013 Tanaka Akira <akr@fsij.org>
|
||||
|
||||
* bignum.c: Add static assertions.
|
||||
|
|
9
struct.c
9
struct.c
|
@ -524,11 +524,20 @@ rb_struct_each_pair(VALUE s)
|
|||
|
||||
RETURN_SIZED_ENUMERATOR(s, 0, 0, struct_enum_size);
|
||||
members = rb_struct_members(s);
|
||||
if (rb_block_arity() > 1) {
|
||||
for (i=0; i<RSTRUCT_LEN(s); i++) {
|
||||
VALUE key = rb_ary_entry(members, i);
|
||||
VALUE value = RSTRUCT_GET(s, i);
|
||||
rb_yield_values(2, key, value);
|
||||
}
|
||||
}
|
||||
else {
|
||||
for (i=0; i<RSTRUCT_LEN(s); i++) {
|
||||
VALUE key = rb_ary_entry(members, i);
|
||||
VALUE value = RSTRUCT_GET(s, i);
|
||||
rb_yield(rb_assoc_new(key, value));
|
||||
}
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче