mirror of
https://github.com/ruby/ruby.git
synced 2025-08-15 13:39:04 +02:00
set.c: use rb_gc_mark_and_move
The `p->field = rb_gc_location(p->field)` isn't ideal because it means all references are rewritten on compaction, regardless of whether the referenced object has moved. This isn't good for caches nor for Copy-on-Write. `rb_gc_mark_and_move` avoid needless writes, and most of the time allow to have a single function for both marking and updating references.
This commit is contained in:
parent
559d9e1f67
commit
5bcfc53d6f
1 changed files with 1 additions and 3 deletions
4
set.c
4
set.c
|
@ -172,9 +172,7 @@ set_foreach_replace(st_data_t key, st_data_t argp, int error)
|
||||||
static int
|
static int
|
||||||
set_replace_ref(st_data_t *key, st_data_t argp, int existing)
|
set_replace_ref(st_data_t *key, st_data_t argp, int existing)
|
||||||
{
|
{
|
||||||
if (rb_gc_location((VALUE)*key) != (VALUE)*key) {
|
rb_gc_mark_and_move((VALUE *)key);
|
||||||
*key = rb_gc_location((VALUE)*key);
|
|
||||||
}
|
|
||||||
|
|
||||||
return ST_CONTINUE;
|
return ST_CONTINUE;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue