Skip to content

Commit 7e991e6

Browse files
authored
Remove checking whether rb_gc_mark_movable exists (#876)
Currently the oj gem supports Ruby 2.7+. rb_gc_mark_movable() has introduced at Ruby 2.7. Ref. https://github.com/ruby/ruby/blob/v2_7_0/include/ruby/intern.h#L540 So, we can use rb_gc_mark_movable() freely in oj gem.
1 parent 3a00e85 commit 7e991e6

2 files changed

Lines changed: 3 additions & 14 deletions

File tree

ext/oj/extconf.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
}
2525

2626
# Support for compaction.
27-
have_func('rb_gc_mark_movable')
2827
have_func('stpcpy')
2928
have_func('pthread_mutex_init')
3029
have_func('rb_enc_interned_str')

ext/oj/fast.c

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,6 @@
2222
// #define BATCH_SIZE (4096 / sizeof(struct _leaf) - 1)
2323
#define BATCH_SIZE 100
2424

25-
// Support for compaction
26-
#ifdef HAVE_RB_GC_MARK_MOVABLE
27-
#define mark rb_gc_mark_movable
28-
#else
29-
#define mark rb_gc_mark
30-
#endif
31-
3225
typedef struct _batch {
3326
struct _batch *next;
3427
int next_avail;
@@ -691,7 +684,7 @@ static void mark_leaf(Leaf leaf) {
691684
} while (e != first);
692685
}
693686
break;
694-
case RUBY_VAL: mark(leaf->value); break;
687+
case RUBY_VAL: rb_gc_mark_movable(leaf->value); break;
695688

696689
default: break;
697690
}
@@ -702,11 +695,11 @@ static void mark_doc(void *ptr) {
702695
if (NULL != ptr) {
703696
Doc doc = (Doc)ptr;
704697

705-
mark(doc->self);
698+
rb_gc_mark_movable(doc->self);
706699
mark_leaf(doc->data);
707700
}
708701
}
709-
#ifdef HAVE_RB_GC_MARK_MOVABLE
702+
710703
static void compact_leaf(Leaf leaf) {
711704
switch (leaf->value_type) {
712705
case COL_VAL:
@@ -734,17 +727,14 @@ static void compact_doc(void *ptr) {
734727
compact_leaf(doc->data);
735728
}
736729
}
737-
#endif
738730

739731
static const rb_data_type_t oj_doc_type = {
740732
"Oj/doc",
741733
{
742734
mark_doc,
743735
free_doc_cb,
744736
NULL,
745-
#ifdef HAVE_RB_GC_MARK_MOVABLE
746737
compact_doc,
747-
#endif
748738
},
749739
0,
750740
0,

0 commit comments

Comments
 (0)