Introduce hash_iter_status_check
function
This commit is contained in:
parent
54cad3123a
commit
c8c136265c
Notes:
git
2022-10-23 07:17:44 +00:00
Merged: https://github.com/ruby/ruby/pull/6564 Merged-By: nobu <nobu@ruby-lang.org>
33
hash.c
33
hash.c
@ -1346,15 +1346,8 @@ struct hash_foreach_arg {
|
||||
};
|
||||
|
||||
static int
|
||||
hash_ar_foreach_iter(st_data_t key, st_data_t value, st_data_t argp, int error)
|
||||
hash_iter_status_check(int status)
|
||||
{
|
||||
struct hash_foreach_arg *arg = (struct hash_foreach_arg *)argp;
|
||||
|
||||
if (error) return ST_STOP;
|
||||
|
||||
int status = (*arg->func)((VALUE)key, (VALUE)value, arg->arg);
|
||||
/* TODO: rehash check? rb_raise(rb_eRuntimeError, "rehash occurred during iteration"); */
|
||||
|
||||
switch (status) {
|
||||
case ST_DELETE:
|
||||
return ST_DELETE;
|
||||
@ -1367,6 +1360,19 @@ hash_ar_foreach_iter(st_data_t key, st_data_t value, st_data_t argp, int error)
|
||||
return ST_CHECK;
|
||||
}
|
||||
|
||||
static int
|
||||
hash_ar_foreach_iter(st_data_t key, st_data_t value, st_data_t argp, int error)
|
||||
{
|
||||
struct hash_foreach_arg *arg = (struct hash_foreach_arg *)argp;
|
||||
|
||||
if (error) return ST_STOP;
|
||||
|
||||
int status = (*arg->func)((VALUE)key, (VALUE)value, arg->arg);
|
||||
/* TODO: rehash check? rb_raise(rb_eRuntimeError, "rehash occurred during iteration"); */
|
||||
|
||||
return hash_iter_status_check(status);
|
||||
}
|
||||
|
||||
static int
|
||||
hash_foreach_iter(st_data_t key, st_data_t value, st_data_t argp, int error)
|
||||
{
|
||||
@ -1381,16 +1387,7 @@ hash_foreach_iter(st_data_t key, st_data_t value, st_data_t argp, int error)
|
||||
rb_raise(rb_eRuntimeError, "rehash occurred during iteration");
|
||||
}
|
||||
|
||||
switch (status) {
|
||||
case ST_DELETE:
|
||||
return ST_DELETE;
|
||||
case ST_CONTINUE:
|
||||
break;
|
||||
case ST_STOP:
|
||||
return ST_STOP;
|
||||
}
|
||||
|
||||
return ST_CHECK;
|
||||
return hash_iter_status_check(status);
|
||||
}
|
||||
|
||||
static int
|
||||
|
Loading…
x
Reference in New Issue
Block a user