Switch sorted list of pages in the GC to a darray

This commit is contained in:
Peter Zhu 2024-09-04 11:59:37 -04:00
parent 16f241f0aa
commit b66d6e48c8
3 changed files with 78 additions and 138 deletions

View file

@ -53,6 +53,19 @@
(*(ptr_to_ary))->meta.size++; \
} while (0)
#define rb_darray_insert(ptr_to_ary, idx, element) do { \
rb_darray_ensure_space((ptr_to_ary), \
sizeof(**(ptr_to_ary)), \
sizeof((*(ptr_to_ary))->data[0])); \
MEMMOVE( \
rb_darray_ref(*(ptr_to_ary), idx + 1), \
rb_darray_ref(*(ptr_to_ary), idx), \
sizeof((*(ptr_to_ary))->data[0]), \
rb_darray_size(*(ptr_to_ary)) - idx); \
rb_darray_set(*(ptr_to_ary), idx, element); \
(*(ptr_to_ary))->meta.size++; \
} while (0)
// Iterate over items of the array in a for loop
//
#define rb_darray_foreach(ary, idx_name, elem_ptr_var) \
@ -108,6 +121,14 @@ rb_darray_size(const void *ary)
return meta ? meta->size : 0;
}
static inline void
rb_darray_pop(void *ary, size_t count)
{
rb_darray_meta_t *meta = ary;
meta->size -= count;
}
// Get the capacity of the dynamic array.
//
static inline size_t