add setter of iter_lev.
* hash.c: add special setter function (inc and dec). * internal.h: constify RHash::iter_leve. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66765 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
140f8b94ce
commit
e3dbe84e12
18
hash.c
18
hash.c
@ -1206,17 +1206,29 @@ hash_foreach_iter(st_data_t key, st_data_t value, st_data_t argp, int error)
|
|||||||
return ST_CHECK;
|
return ST_CHECK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
hash_iter_lev_inc(VALUE hash)
|
||||||
|
{
|
||||||
|
*((int *)&RHASH(hash)->iter_lev) = RHASH_ITER_LEV(hash) + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
hash_iter_lev_dec(VALUE hash)
|
||||||
|
{
|
||||||
|
*((int *)&RHASH(hash)->iter_lev) = RHASH_ITER_LEV(hash) - 1;
|
||||||
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
hash_foreach_ensure_rollback(VALUE hash)
|
hash_foreach_ensure_rollback(VALUE hash)
|
||||||
{
|
{
|
||||||
RHASH_ITER_LEV(hash)++;
|
hash_iter_lev_inc(hash);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
hash_foreach_ensure(VALUE hash)
|
hash_foreach_ensure(VALUE hash)
|
||||||
{
|
{
|
||||||
RHASH_ITER_LEV(hash)--;
|
hash_iter_lev_dec(hash);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1257,7 +1269,7 @@ rb_hash_foreach(VALUE hash, int (*func)(ANYARGS), VALUE farg)
|
|||||||
|
|
||||||
if (RHASH_TABLE_EMPTY_P(hash))
|
if (RHASH_TABLE_EMPTY_P(hash))
|
||||||
return;
|
return;
|
||||||
RHASH_ITER_LEV(hash)++;
|
hash_iter_lev_inc(hash);
|
||||||
arg.hash = hash;
|
arg.hash = hash;
|
||||||
arg.func = (rb_foreach_func *)func;
|
arg.func = (rb_foreach_func *)func;
|
||||||
arg.arg = farg;
|
arg.arg = farg;
|
||||||
|
@ -806,7 +806,7 @@ struct RHash {
|
|||||||
st_table *st;
|
st_table *st;
|
||||||
struct ar_table_struct *ar; /* possibly 0 */
|
struct ar_table_struct *ar; /* possibly 0 */
|
||||||
} as;
|
} as;
|
||||||
int iter_lev;
|
const int iter_lev;
|
||||||
const VALUE ifnone;
|
const VALUE ifnone;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user