mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
enum.c: hosited out enum_hashify
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67019 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
fb84b86be0
commit
e0f1b514d2
1 changed files with 11 additions and 11 deletions
22
enum.c
22
enum.c
|
@ -611,6 +611,15 @@ enum_to_a(int argc, VALUE *argv, VALUE obj)
|
||||||
return ary;
|
return ary;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static VALUE
|
||||||
|
enum_hashify(VALUE obj, int argc, const VALUE *argv, rb_block_call_func *iter)
|
||||||
|
{
|
||||||
|
VALUE hash = rb_hash_new();
|
||||||
|
rb_block_call(obj, id_each, argc, argv, iter, hash);
|
||||||
|
OBJ_INFECT(hash, obj);
|
||||||
|
return hash;
|
||||||
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
enum_to_h_i(RB_BLOCK_CALL_FUNC_ARGLIST(i, hash))
|
enum_to_h_i(RB_BLOCK_CALL_FUNC_ARGLIST(i, hash))
|
||||||
{
|
{
|
||||||
|
@ -647,11 +656,8 @@ enum_to_h_ii(RB_BLOCK_CALL_FUNC_ARGLIST(i, hash))
|
||||||
static VALUE
|
static VALUE
|
||||||
enum_to_h(int argc, VALUE *argv, VALUE obj)
|
enum_to_h(int argc, VALUE *argv, VALUE obj)
|
||||||
{
|
{
|
||||||
VALUE hash = rb_hash_new();
|
|
||||||
rb_block_call_func *iter = rb_block_given_p() ? enum_to_h_ii : enum_to_h_i;
|
rb_block_call_func *iter = rb_block_given_p() ? enum_to_h_ii : enum_to_h_i;
|
||||||
rb_block_call(obj, id_each, argc, argv, iter, hash);
|
return enum_hashify(obj, argc, argv, iter);
|
||||||
OBJ_INFECT(hash, obj);
|
|
||||||
return hash;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
|
@ -924,15 +930,9 @@ group_by_i(RB_BLOCK_CALL_FUNC_ARGLIST(i, hash))
|
||||||
static VALUE
|
static VALUE
|
||||||
enum_group_by(VALUE obj)
|
enum_group_by(VALUE obj)
|
||||||
{
|
{
|
||||||
VALUE hash;
|
|
||||||
|
|
||||||
RETURN_SIZED_ENUMERATOR(obj, 0, 0, enum_size);
|
RETURN_SIZED_ENUMERATOR(obj, 0, 0, enum_size);
|
||||||
|
|
||||||
hash = rb_hash_new();
|
return enum_hashify(obj, 0, 0, group_by_i);
|
||||||
rb_block_call(obj, id_each, 0, 0, group_by_i, hash);
|
|
||||||
OBJ_INFECT(hash, obj);
|
|
||||||
|
|
||||||
return hash;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
|
|
Loading…
Add table
Reference in a new issue