Implement dcompact
for Time objects
This commit is contained in:
parent
7db0e07134
commit
8a475d15d6
Notes:
git
2025-03-31 14:56:46 +00:00
41
time.c
41
time.c
@ -1890,23 +1890,38 @@ static void
|
|||||||
time_mark(void *ptr)
|
time_mark(void *ptr)
|
||||||
{
|
{
|
||||||
struct time_object *tobj = ptr;
|
struct time_object *tobj = ptr;
|
||||||
if (!FIXWV_P(tobj->timew))
|
if (!FIXWV_P(tobj->timew)) {
|
||||||
rb_gc_mark(w2v(tobj->timew));
|
rb_gc_mark_movable(WIDEVAL_GET(tobj->timew));
|
||||||
rb_gc_mark(tobj->vtm.year);
|
}
|
||||||
rb_gc_mark(tobj->vtm.subsecx);
|
rb_gc_mark_movable(tobj->vtm.year);
|
||||||
rb_gc_mark(tobj->vtm.utc_offset);
|
rb_gc_mark_movable(tobj->vtm.subsecx);
|
||||||
rb_gc_mark(tobj->vtm.zone);
|
rb_gc_mark_movable(tobj->vtm.utc_offset);
|
||||||
|
rb_gc_mark_movable(tobj->vtm.zone);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
time_compact(void *ptr)
|
||||||
|
{
|
||||||
|
struct time_object *tobj = ptr;
|
||||||
|
if (!FIXWV_P(tobj->timew)) {
|
||||||
|
WIDEVAL_GET(tobj->timew) = rb_gc_location(WIDEVAL_GET(tobj->timew));
|
||||||
|
}
|
||||||
|
|
||||||
|
tobj->vtm.year = rb_gc_location(tobj->vtm.year);
|
||||||
|
tobj->vtm.subsecx = rb_gc_location(tobj->vtm.subsecx);
|
||||||
|
tobj->vtm.utc_offset = rb_gc_location(tobj->vtm.utc_offset);
|
||||||
|
tobj->vtm.zone = rb_gc_location(tobj->vtm.zone);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const rb_data_type_t time_data_type = {
|
static const rb_data_type_t time_data_type = {
|
||||||
"time",
|
.wrap_struct_name = "time",
|
||||||
{
|
.function = {
|
||||||
time_mark,
|
.dmark = time_mark,
|
||||||
RUBY_TYPED_DEFAULT_FREE,
|
.dfree = RUBY_TYPED_DEFAULT_FREE,
|
||||||
NULL, // No external memory to report,
|
.dsize = NULL,
|
||||||
|
.dcompact = time_compact,
|
||||||
},
|
},
|
||||||
0, 0,
|
.flags = RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_FROZEN_SHAREABLE | RUBY_TYPED_WB_PROTECTED | RUBY_TYPED_EMBEDDABLE,
|
||||||
(RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_FROZEN_SHAREABLE | RUBY_TYPED_WB_PROTECTED | RUBY_TYPED_EMBEDDABLE),
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
|
Loading…
x
Reference in New Issue
Block a user