Skip to content

Commit 8dfe3bd

Browse files
authored
Improved formatting of hash_foreach_iter functions. (#6615)
1 parent 420bdba commit 8dfe3bd

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

hash.c

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1349,10 +1349,10 @@ static int
13491349
hash_ar_foreach_iter(st_data_t key, st_data_t value, st_data_t argp, int error)
13501350
{
13511351
struct hash_foreach_arg *arg = (struct hash_foreach_arg *)argp;
1352-
int status;
13531352

13541353
if (error) return ST_STOP;
1355-
status = (*arg->func)((VALUE)key, (VALUE)value, arg->arg);
1354+
1355+
int status = (*arg->func)((VALUE)key, (VALUE)value, arg->arg);
13561356
/* TODO: rehash check? rb_raise(rb_eRuntimeError, "rehash occurred during iteration"); */
13571357

13581358
switch (status) {
@@ -1363,22 +1363,24 @@ hash_ar_foreach_iter(st_data_t key, st_data_t value, st_data_t argp, int error)
13631363
case ST_STOP:
13641364
return ST_STOP;
13651365
}
1366+
13661367
return ST_CHECK;
13671368
}
13681369

13691370
static int
13701371
hash_foreach_iter(st_data_t key, st_data_t value, st_data_t argp, int error)
13711372
{
13721373
struct hash_foreach_arg *arg = (struct hash_foreach_arg *)argp;
1373-
int status;
1374-
st_table *tbl;
13751374

13761375
if (error) return ST_STOP;
1377-
tbl = RHASH_ST_TABLE(arg->hash);
1378-
status = (*arg->func)((VALUE)key, (VALUE)value, arg->arg);
1376+
1377+
st_table *tbl = RHASH_ST_TABLE(arg->hash);
1378+
int status = (*arg->func)((VALUE)key, (VALUE)value, arg->arg);
1379+
13791380
if (RHASH_ST_TABLE(arg->hash) != tbl) {
1380-
rb_raise(rb_eRuntimeError, "rehash occurred during iteration");
1381+
rb_raise(rb_eRuntimeError, "rehash occurred during iteration");
13811382
}
1383+
13821384
switch (status) {
13831385
case ST_DELETE:
13841386
return ST_DELETE;
@@ -1387,6 +1389,7 @@ hash_foreach_iter(st_data_t key, st_data_t value, st_data_t argp, int error)
13871389
case ST_STOP:
13881390
return ST_STOP;
13891391
}
1392+
13901393
return ST_CHECK;
13911394
}
13921395

0 commit comments

Comments
 (0)