20#include "internal/gc.h"
45#define ARY_DEFAULT_SIZE 16
46#define ARY_MAX_SIZE (LONG_MAX / (int)sizeof(VALUE))
47#define SMALL_ARRAY_LEN 16
51should_be_T_ARRAY(
VALUE ary)
58should_not_be_shared_and_embedded(
VALUE ary)
63#define ARY_SHARED_P(ary) \
64 (assert(should_be_T_ARRAY((VALUE)(ary))), \
65 assert(should_not_be_shared_and_embedded((VALUE)ary)), \
66 FL_TEST_RAW((ary),ELTS_SHARED)!=0)
68#define ARY_EMBED_P(ary) \
69 (assert(should_be_T_ARRAY((VALUE)(ary))), \
70 assert(should_not_be_shared_and_embedded((VALUE)ary)), \
71 FL_TEST_RAW((ary), RARRAY_EMBED_FLAG) != 0)
73#define ARY_HEAP_PTR(a) (assert(!ARY_EMBED_P(a)), RARRAY(a)->as.heap.ptr)
74#define ARY_HEAP_LEN(a) (assert(!ARY_EMBED_P(a)), RARRAY(a)->as.heap.len)
75#define ARY_HEAP_CAPA(a) (assert(!ARY_EMBED_P(a)), assert(!ARY_SHARED_ROOT_P(a)), \
76 RARRAY(a)->as.heap.aux.capa)
78#define ARY_EMBED_PTR(a) (assert(ARY_EMBED_P(a)), RARRAY(a)->as.ary)
79#define ARY_EMBED_LEN(a) \
80 (assert(ARY_EMBED_P(a)), \
81 (long)((RBASIC(a)->flags >> RARRAY_EMBED_LEN_SHIFT) & \
82 (RARRAY_EMBED_LEN_MASK >> RARRAY_EMBED_LEN_SHIFT)))
83#define ARY_HEAP_SIZE(a) (assert(!ARY_EMBED_P(a)), assert(ARY_OWNS_HEAP_P(a)), ARY_CAPA(a) * sizeof(VALUE))
85#define ARY_OWNS_HEAP_P(a) (assert(should_be_T_ARRAY((VALUE)(a))), \
86 !FL_TEST_RAW((a), ELTS_SHARED|RARRAY_EMBED_FLAG))
88#define FL_SET_EMBED(a) do { \
89 assert(!ARY_SHARED_P(a)); \
90 FL_SET((a), RARRAY_EMBED_FLAG); \
91 RARY_TRANSIENT_UNSET(a); \
95#define FL_UNSET_EMBED(ary) FL_UNSET((ary), RARRAY_EMBED_FLAG|RARRAY_EMBED_LEN_MASK)
96#define FL_SET_SHARED(ary) do { \
97 assert(!ARY_EMBED_P(ary)); \
98 FL_SET((ary), ELTS_SHARED); \
100#define FL_UNSET_SHARED(ary) FL_UNSET((ary), ELTS_SHARED)
102#define ARY_SET_PTR(ary, p) do { \
103 assert(!ARY_EMBED_P(ary)); \
104 assert(!OBJ_FROZEN(ary)); \
105 RARRAY(ary)->as.heap.ptr = (p); \
107#define ARY_SET_EMBED_LEN(ary, n) do { \
109 assert(ARY_EMBED_P(ary)); \
110 assert(!OBJ_FROZEN(ary)); \
111 RBASIC(ary)->flags &= ~RARRAY_EMBED_LEN_MASK; \
112 RBASIC(ary)->flags |= (tmp_n) << RARRAY_EMBED_LEN_SHIFT; \
114#define ARY_SET_HEAP_LEN(ary, n) do { \
115 assert(!ARY_EMBED_P(ary)); \
116 RARRAY(ary)->as.heap.len = (n); \
118#define ARY_SET_LEN(ary, n) do { \
119 if (ARY_EMBED_P(ary)) { \
120 ARY_SET_EMBED_LEN((ary), (n)); \
123 ARY_SET_HEAP_LEN((ary), (n)); \
125 assert(RARRAY_LEN(ary) == (n)); \
127#define ARY_INCREASE_PTR(ary, n) do { \
128 assert(!ARY_EMBED_P(ary)); \
129 assert(!OBJ_FROZEN(ary)); \
130 RARRAY(ary)->as.heap.ptr += (n); \
132#define ARY_INCREASE_LEN(ary, n) do { \
133 assert(!OBJ_FROZEN(ary)); \
134 if (ARY_EMBED_P(ary)) { \
135 ARY_SET_EMBED_LEN((ary), RARRAY_LEN(ary)+(n)); \
138 RARRAY(ary)->as.heap.len += (n); \
142#define ARY_CAPA(ary) (ARY_EMBED_P(ary) ? RARRAY_EMBED_LEN_MAX : \
143 ARY_SHARED_ROOT_P(ary) ? RARRAY_LEN(ary) : ARY_HEAP_CAPA(ary))
144#define ARY_SET_CAPA(ary, n) do { \
145 assert(!ARY_EMBED_P(ary)); \
146 assert(!ARY_SHARED_P(ary)); \
147 assert(!OBJ_FROZEN(ary)); \
148 RARRAY(ary)->as.heap.aux.capa = (n); \
151#define ARY_SHARED_ROOT(ary) (assert(ARY_SHARED_P(ary)), RARRAY(ary)->as.heap.aux.shared_root)
152#define ARY_SET_SHARED(ary, value) do { \
153 const VALUE _ary_ = (ary); \
154 const VALUE _value_ = (value); \
155 assert(!ARY_EMBED_P(_ary_)); \
156 assert(ARY_SHARED_P(_ary_)); \
157 assert(ARY_SHARED_ROOT_P(_value_)); \
158 RB_OBJ_WRITE(_ary_, &RARRAY(_ary_)->as.heap.aux.shared_root, _value_); \
160#define RARRAY_SHARED_ROOT_FLAG FL_USER5
161#define ARY_SHARED_ROOT_P(ary) (assert(should_be_T_ARRAY((VALUE)(ary))), \
162 FL_TEST_RAW((ary), RARRAY_SHARED_ROOT_FLAG))
163#define ARY_SHARED_ROOT_REFCNT(ary) \
164 (assert(ARY_SHARED_ROOT_P(ary)), RARRAY(ary)->as.heap.aux.capa)
165#define ARY_SHARED_ROOT_OCCUPIED(ary) (ARY_SHARED_ROOT_REFCNT(ary) == 1)
166#define ARY_SET_SHARED_ROOT_REFCNT(ary, value) do { \
167 assert(ARY_SHARED_ROOT_P(ary)); \
168 RARRAY(ary)->as.heap.aux.capa = (value); \
170#define FL_SET_SHARED_ROOT(ary) do { \
171 assert(!ARY_EMBED_P(ary)); \
172 assert(!RARRAY_TRANSIENT_P(ary)); \
173 FL_SET((ary), RARRAY_SHARED_ROOT_FLAG); \
182 RARRAY_ASET(a, i, v);
188#define ary_verify(ary) ary_verify_(ary, __FILE__, __LINE__)
191ary_verify_(
VALUE ary,
const char *
file,
int line)
205 assert(!RARRAY_TRANSIENT_P(ary));
215 for (i=0; i<
len; i++) {
222#if USE_TRANSIENT_HEAP
223 if (RARRAY_TRANSIENT_P(ary)) {
234rb_ary_verify(
VALUE ary)
239#define ary_verify(ary) ((void)0)
268ary_mem_clear(
VALUE ary,
long beg,
long size)
276memfill(
register VALUE *mem,
register long size,
register VALUE val)
306 for (i=0; i<
argc; i++) {
316 ary_memcpy0(ary, beg,
argc,
argv, ary);
320ary_heap_alloc(
VALUE ary,
size_t capa)
325 RARY_TRANSIENT_SET(ary);
328 RARY_TRANSIENT_UNSET(ary);
338 if (RARRAY_TRANSIENT_P(ary)) {
347ary_heap_free(
VALUE ary)
349 if (RARRAY_TRANSIENT_P(ary)) {
350 RARY_TRANSIENT_UNSET(ary);
358ary_heap_realloc(
VALUE ary,
size_t new_capa)
362 if (RARRAY_TRANSIENT_P(ary)) {
363 if (new_capa <= old_capa) {
369 if (new_ptr ==
NULL) {
371 RARY_TRANSIENT_UNSET(ary);
384#if USE_TRANSIENT_HEAP
386rb_ary_transient_heap_evacuate_(
VALUE ary,
int transient,
int promote)
399 assert(RARRAY_TRANSIENT_P(ary));
400 assert(!ARY_PTR_USING_P(ary));
404 RARY_TRANSIENT_UNSET(ary);
407 new_ptr = ary_heap_alloc(ary, capa);
412 RARRAY(ary)->as.heap.ptr = new_ptr;
421 rb_ary_transient_heap_evacuate_(ary, RARRAY_TRANSIENT_P(ary), promote);
427 assert(RARRAY_TRANSIENT_P(ary));
428 rb_ary_transient_heap_evacuate_(ary,
TRUE,
TRUE);
439ary_resize_capa(
VALUE ary,
long capacity)
448 VALUE *
ptr = ary_heap_alloc(ary, capacity);
456 ary_heap_realloc(ary, capacity);
466 if (
len > capacity)
len = capacity;
468 ary_heap_free_ptr(ary,
ptr, old_capa);
479ary_shrink_capa(
VALUE ary)
484 assert(old_capa >= capacity);
485 if (old_capa > capacity) ary_heap_realloc(ary, capacity);
491ary_double_capa(
VALUE ary,
long min)
502 ary_resize_capa(ary, new_capa);
508rb_ary_decrement_share(
VALUE shared_root)
523rb_ary_unshare(
VALUE ary)
525 VALUE shared_root =
RARRAY(ary)->as.heap.aux.shared_root;
526 rb_ary_decrement_share(shared_root);
531rb_ary_unshare_safe(
VALUE ary)
539rb_ary_increment_share(
VALUE shared_root)
549rb_ary_set_shared(
VALUE ary,
VALUE shared_root)
551 rb_ary_increment_share(shared_root);
558rb_ary_modify_check(
VALUE ary)
578 rb_ary_decrement_share(shared_root);
590 rb_ary_decrement_share(shared_root);
608 rb_ary_modify_check(ary);
613ary_ensure_room_for_push(
VALUE ary,
long add_len)
616 long new_len = old_len + add_len;
627 rb_ary_modify_check(ary);
637 if (new_len > capa - (capa >> 6)) {
638 ary_double_capa(ary, new_len);
649 rb_ary_modify_check(ary);
652 if (new_len > capa) {
653 ary_double_capa(ary, new_len);
691 RARRAY(ary1)->as.heap.aux.shared_root ==
RARRAY(ary2)->as.heap.aux.shared_root &&
692 RARRAY(ary1)->as.heap.len ==
RARRAY(ary2)->as.heap.len) {
699ary_alloc(
VALUE klass)
710empty_ary_alloc(
VALUE klass)
713 return ary_alloc(klass);
717ary_new(
VALUE klass,
long capa)
730 ary = ary_alloc(klass);
732 ptr = ary_heap_alloc(ary, capa);
764 for (i=0; i<n; i++) {
765 ARY_SET(ary, i, va_arg(ar,
VALUE));
778 ary = ary_new(klass, n);
780 ary_memcpy(ary, 0, n, elts);
818 ary = ec_ary_alloc(ec, klass);
821 ptr = ary_heap_alloc(ary, capa);
838 ary_memcpy(ary, 0, n, elts);
848 VALUE ary = ary_new(0, capa);
856 VALUE ary = ary_new(0, capa);
857 ary_memfill(ary, 0, capa,
Qnil);
873 if (RARRAY_TRANSIENT_P(ary)) {
893RUBY_FUNC_EXPORTED
size_t
905ary_discard(
VALUE ary)
913ary_make_shared(
VALUE ary)
926 ary_shrink_capa(ary);
943 ary_mem_clear(vshared,
len, capa -
len);
959ary_make_substitution(
VALUE ary)
970 return rb_ary_increment_share(ary_make_shared(ary));
985#define to_ary rb_to_array_type
1074 rb_ary_unshare_safe(ary);
1101 ary_resize_capa(ary,
len);
1106 rb_warn(
"block supersedes default value argument");
1108 for (i=0; i<
len; i++) {
1114 ary_memfill(ary, 0,
len, val);
1158 ary_double_capa(ary, idx);
1161 ary_mem_clear(ary,
len, idx -
len + 1);
1167 ARY_SET(ary, idx, val);
1178 VALUE result = ary_alloc(klass);
1184 VALUE shared, result = ary_alloc(klass);
1187 shared = ary_make_shared(ary);
1190 rb_ary_set_shared(result, shared);
1210 const long orig_len =
len;
1212 if ((step > 0 && step >=
len) || (step < 0 && (step < -
len))) {
1213 VALUE result = ary_new(klass, 1);
1220 long ustep = (step < 0) ? -step : step;
1221 len = (
len + ustep - 1) / ustep;
1224 long j =
offset + ((step > 0) ? 0 : (orig_len - 1));
1225 VALUE result = ary_new(klass,
len);
1228 for (i = 0; i <
len; ++i) {
1236 for (i = 0; i <
len; ++i) {
1248ary_make_shared_copy(
VALUE ary)
1304 VALUE target_ary = ary_ensure_room_for_push(ary, 1);
1317 VALUE target_ary = ary_ensure_room_for_push(ary,
len);
1318 ary_memcpy0(ary, oldlen,
len,
argv, target_ary);
1353 rb_ary_modify_check(ary);
1355 if (n == 0)
return Qnil;
1360 ary_resize_capa(ary, n * 2);
1405 rb_ary_modify_check(ary);
1418 rb_ary_modify_check(ary);
1432 ARY_SET(ary, 0,
Qnil);
1433 ary_make_shared(ary);
1486 rb_ary_modify_check(ary);
1495behead_shared(
VALUE ary,
long n)
1498 rb_ary_modify_check(ary);
1500 ary_mem_clear(ary, 0, n);
1509behead_transient(
VALUE ary,
long n)
1511 rb_ary_modify_check(ary);
1527 return behead_shared(ary, n);
1530 ary_make_shared(ary);
1531 return behead_shared(ary, n);
1534 return behead_transient(ary, n);
1541 if (head - sharedp <
argc) {
1542 long room = capa -
len -
argc;
1546 head = sharedp +
argc + room;
1556ary_modify_for_unshift(
VALUE ary,
int argc)
1561 const VALUE *head, *sharedp;
1565 if (capa - (capa >> 6) <= new_len) {
1566 ary_double_capa(ary, new_len);
1575 ary_make_shared(ary);
1578 return make_room_for_unshift(ary, head, (
void *)sharedp,
argc, capa,
len);
1592ary_ensure_room_for_unshift(
VALUE ary,
int argc)
1601 return ary_modify_for_unshift(ary,
argc);
1608 return ary_modify_for_unshift(ary,
argc);
1610 else if (new_len > capa) {
1611 return ary_modify_for_unshift(ary,
argc);
1617 rb_ary_modify_check(ary);
1618 return make_room_for_unshift(ary, head, sharedp,
argc, capa,
len);
1643 rb_ary_modify_check(ary);
1647 target_ary = ary_ensure_room_for_unshift(ary,
argc);
1648 ary_memcpy0(ary, 0,
argc,
argv, target_ary);
1656 return rb_ary_unshift_m(1,&item,ary);
1674 return rb_ary_entry_internal(ary,
offset);
1683 if (beg > alen)
return Qnil;
1684 if (beg < 0 ||
len < 0)
return Qnil;
1686 if (alen <
len || alen < beg +
len) {
1690 if (
len == 0)
return ary_new(klass, 0);
1694 return ary_make_partial(ary, klass, beg,
len);
1696 return ary_make_partial_step(ary, klass, beg,
len, step);
1806 return rb_ary_aref2(ary,
argv[0],
argv[1]);
1825 long beg,
len, step;
1986 if (block_given &&
argc == 2) {
1987 rb_warn(
"block supersedes default value argument");
1995 if (block_given)
return rb_yield(pos);
2058 rb_warn(
"given block not used");
2119 rb_warn(
"given block not used");
2137 if (!
NIL_P(tmp))
return tmp;
2142rb_ary_splice(
VALUE ary,
long beg,
long len,
const VALUE *rptr,
long rlen)
2156 if (olen <
len || olen < beg +
len) {
2162 rofs = (rptr >= optr && rptr < optr + olen) ? rptr - optr : -1;
2170 target_ary = ary_ensure_room_for_push(ary, rlen-
len);
2172 ary_mem_clear(ary, olen, beg - olen);
2175 ary_memcpy0(ary, beg, rlen, rptr, target_ary);
2186 alen = olen + rlen -
len;
2188 ary_double_capa(ary, alen);
2216 rb_ary_modify_check(ary);
2221 rb_bug(
"probable buffer overflow: %ld for %ld",
len, capa);
2241 if (
len == olen)
return ary;
2247 ary_double_capa(ary,
len);
2249 ary_mem_clear(ary, olen,
len - olen);
2264 ary_heap_realloc(ary,
len);
2281ary_aset_by_rb_ary_splice(
VALUE ary,
long beg,
long len,
VALUE val)
2394 rb_ary_modify_check(ary);
2398 return ary_aset_by_rb_ary_splice(ary, beg,
len,
argv[2]);
2402 return ary_aset_by_rb_ary_store(ary,
offset,
argv[1]);
2406 return ary_aset_by_rb_ary_splice(ary, beg,
len,
argv[1]);
2410 return ary_aset_by_rb_ary_store(ary,
offset,
argv[1]);
2450 rb_ary_modify_check(ary);
2452 if (
argc == 1)
return ary;
2464 rb_ary_splice(ary, pos, 0,
argv + 1,
argc - 1);
2469rb_ary_length(
VALUE ary);
2474 return rb_ary_length(ary);
2568rb_ary_each_index(
VALUE ary)
2618rb_ary_reverse_each(
VALUE ary)
2643rb_ary_length(
VALUE ary)
2658rb_ary_empty_p(
VALUE ary)
2694 VALUE result = arg[2];
2695 int *first = (
int *)arg[3];
2701 ary_join_1(obj, ary, sep, 0, result, first);
2713 for (i=0; i<
max; i++) {
2715 if (!RB_TYPE_P(val,
T_STRING))
break;
2716 if (i > 0 && !
NIL_P(sep))
2724ary_join_1_str(
VALUE dst,
VALUE src,
int *first)
2746 args[3] = (
VALUE)first;
2757 if (i > 0 && !
NIL_P(sep))
2762 ary_join_1_str(result, val, first);
2764 else if (RB_TYPE_P(val,
T_ARRAY)) {
2765 ary_join_1_ary(val, ary, sep, result, val, first);
2768 ary_join_1_str(result, tmp, first);
2771 ary_join_1_ary(val, ary, sep, result, tmp, first);
2783 VALUE val, tmp, result;
2795 if (
NIL_P(tmp) || tmp != val) {
2801 i = ary_join_0(ary, sep, i, result);
2803 ary_join_1(ary, ary, sep, i, result, &first);
2813 ary_join_0(ary, sep,
RARRAY_LEN(ary), result);
2887rb_ary_inspect(
VALUE ary)
2896 return rb_ary_inspect(ary);
2918rb_ary_to_a(
VALUE ary)
2951rb_ary_to_h(
VALUE ary)
2958 const VALUE e = rb_ary_elt(ary, i);
2961 if (
NIL_P(key_value_pair)) {
2982rb_ary_to_ary_m(
VALUE ary)
3007 ary_reverse(p1, p2);
3023rb_ary_reverse_bang(
VALUE ary)
3039rb_ary_reverse_m(
VALUE ary)
3047 do *p2-- = *p1++;
while (--
len > 0);
3054rotate_count(
long cnt,
long len)
3066 }
else if (
cnt ==
len - 1) {
3209sort_reentered(
VALUE ary)
3211 if (
RBASIC(ary)->klass) {
3218sort_1(
const void *ap,
const void *
bp,
void *dummy)
3221 VALUE retval = sort_reentered(data->
ary);
3230 sort_reentered(data->
ary);
3235sort_2(
const void *ap,
const void *
bp,
void *dummy)
3238 VALUE retval = sort_reentered(data->
ary);
3243 if ((
long)a > (
long)b)
return 1;
3244 if ((
long)a < (
long)b)
return -1;
3256 sort_reentered(data->
ary);
3303 VALUE tmp = ary_make_substitution(
ary);
3306 RBASIC_CLEAR_CLASS(tmp);
3317 rb_ary_unshare(
ary);
3335 rb_ary_unshare(
ary);
3499 VALUE index_result = rb_ary_bsearch_index(
ary);
3504 return index_result;
3520 int smaller = 0, satisfied = 0;
3524 while (low < high) {
3525 mid = low + ((high - low) / 2);
3532 else if (v ==
Qtrue) {
3549 " (must be numeric, true, false or nil)",
3559 if (!satisfied)
return Qnil;
3676 long beg,
len, i, j;
3678 for (i=0; i<
argc; i++) {
3685 long end = olen < beg+
len ? olen : beg+
len;
3686 for (j = beg; j < end; j++) {
3709 const long end = beg +
len;
3765 for (i = 0; i <
argc; ++i) {
3766 append_values_at_single(result,
ary, olen,
argv[i]);
3814select_bang_i(
VALUE a)
3828 return (i1 == i2) ?
Qnil :
ary;
3832select_bang_ensure(
VALUE a)
3837 long i1 = arg->
len[0], i2 = arg->
len[1];
3839 if (i2 <
len && i2 < i1) {
3883 args.len[0] = args.len[1] = 0;
3906 rb_ary_select_bang(
ary);
3918 ary_resize_capa(
ary,
len * 2);
3980 ary_resize_smaller(
ary, i2);
4006 ary_resize_smaller(
ary, i2);
4018 if (pos < 0)
return Qnil;
4059ary_slice_bang_by_rb_ary_splice(
VALUE ary,
long pos,
long len)
4066 else if (pos < -orig_len) {
4072 else if (orig_len < pos) {
4075 if (orig_len < pos +
len) {
4076 len = orig_len - pos;
4083 rb_ary_splice(
ary, pos,
len, 0, 0);
4155 rb_ary_modify_check(
ary);
4162 return ary_slice_bang_by_rb_ary_splice(
ary, pos,
len);
4169 return ary_slice_bang_by_rb_ary_splice(
ary, pos,
len);
4198reject_bang_i(
VALUE a)
4212 return (i1 == i2) ?
Qnil :
ary;
4219 rb_ary_modify_check(
ary);
4221 args.len[0] = args.len[1] = 0;
4248 return ary_reject_bang(
ary);
4274 ary_reject(
ary, rejected_ary);
4275 return rejected_ary;
4298 ary_reject_bang(
ary);
4314take_items(
VALUE obj,
long n)
4321 args[0] = result; args[1] = (
VALUE)n;
4385 for (i=0; i<
argc; i++) {
4399 for (j=0; j<
argc; j++) {
4400 tmp[j+1] = rb_ary_elt(
argv[j], i);
4412 for (j=0; j<
argc; j++) {
4422 for (i=0; i<
len; i++) {
4426 for (j=0; j<
argc; j++) {
4449 long elen = -1, alen, i, j;
4450 VALUE tmp, result = 0;
4454 for (i=0; i<alen; i++) {
4459 for (j=0; j<elen; j++) {
4467 for (j=0; j<elen; j++) {
4468 rb_ary_store(rb_ary_elt(result, j), i, rb_ary_elt(tmp, j));
4486 rb_ary_modify_check(copy);
4488 if (copy == orig)
return copy;
4491 VALUE shared_root = 0;
4494 ary_heap_free(copy);
4503 rb_ary_decrement_share(shared_root);
4508 VALUE shared_root = ary_make_shared(orig);
4510 ary_heap_free(copy);
4513 rb_ary_unshare_safe(copy);
4518 rb_ary_set_shared(copy, shared_root);
4536 rb_ary_modify_check(
ary);
4539 rb_ary_unshare(
ary);
4727 long beg = 0, end = 0,
len = 0;
4750 if (beg < 0) beg = 0;
4765 ary_resize_capa(
ary, end);
4775 for (i=beg; i<end; i++) {
4782 ary_memfill(
ary, beg,
len, item);
4803 long len, xlen, ylen;
4840 rb_ary_modify_check(
ary);
4845 else if (
argc > 1) {
4848 for (i = 0; i <
argc; i++) {
4851 ary_append(
ary, args);
4861 return ary_append(x,
to_ary(y));
4910 ary_memcpy(ary2, 0,
t,
ptr);
4911 while (
t <=
len/2) {
4986 const VALUE *p1, *p2;
4995 for (i = 0; i < len1; i++) {
5036 if (ary1 == ary2)
return Qtrue;
5037 if (!RB_TYPE_P(ary2,
T_ARRAY)) {
5055 if (!
rb_eql(rb_ary_elt(ary1, i), rb_ary_elt(ary2, i)))
5080 if (ary1 == ary2)
return Qtrue;
5165 for (i=0; i<
len; i++) {
5166 VALUE e1 = rb_ary_elt(ary1, i), e2 = rb_ary_elt(ary2, i);
5205 if (ary1 == ary2)
return INT2FIX(0);
5207 if (v !=
Qundef)
return v;
5232 RBASIC_CLEAR_CLASS(hash);
5239 VALUE hash = ary_tmp_hash_new(
ary);
5240 return ary_add_hash(hash,
ary);
5258 VALUE hash = ary_tmp_hash_new(
ary);
5259 return ary_add_hash_by(hash,
ary);
5263ary_recycle_hash(
VALUE hash)
5266 if (RHASH_ST_TABLE_P(hash)) {
5267 st_table *tbl = RHASH_ST_TABLE(hash);
5269 RHASH_ST_CLEAR(hash);
5300 VALUE elt = rb_ary_elt(ary1, i);
5301 if (rb_ary_includes_by_eql(ary2, elt))
continue;
5307 hash = ary_make_hash(ary2);
5312 ary_recycle_hash(hash);
5342 for (i = 0; i <
argc; i++) {
5345 if (is_hash[i])
argv[i] = ary_make_hash(
argv[i]);
5351 for (j = 0; j <
argc; j++) {
5357 if (rb_ary_includes_by_eql(
argv[j], elt))
break;
5388 VALUE hash, ary3, v;
5399 if (!rb_ary_includes_by_eql(ary2, v))
continue;
5400 if (rb_ary_includes_by_eql(ary3, v))
continue;
5406 hash = ary_make_hash(ary2);
5415 ary_recycle_hash(hash);
5444 for (i = 0; i <
argc; i++) {
5445 result = rb_ary_and(result,
argv[i]);
5465 if (rb_ary_includes_by_eql(ary_union, elt))
continue;
5504 rb_ary_union(ary3, ary1);
5505 rb_ary_union(ary3, ary2);
5509 hash = ary_make_hash(ary1);
5510 rb_ary_union_hash(hash, ary2);
5513 ary_recycle_hash(hash);
5537 VALUE hash, ary_union;
5540 for (i = 0; i <
argc; i++) {
5548 rb_ary_union(ary_union,
ary);
5549 for (i = 0; i <
argc; i++) rb_ary_union(ary_union,
argv[i]);
5554 hash = ary_make_hash(
ary);
5555 for (i = 0; i <
argc; i++) rb_ary_union_hash(hash,
argv[i]);
5558 ary_recycle_hash(hash);
5587 for (; i < n; ++i) {
5591 if ((
long)vmax < (
long)v) {
5596 return ary_max_generic(
ary, i, vmax);
5611 for (; i < n; ++i) {
5614 if (RB_FLOAT_TYPE_P(v)) {
5620 return ary_max_generic(
ary, i, vmax);
5635 for (; i < n; ++i) {
5644 return ary_max_generic(
ary, i, vmax);
5708 return ary_max_opt_fixnum(ary, 1, result);
5711 return ary_max_opt_string(ary, 1, result);
5713 else if (RB_FLOAT_TYPE_P(result) &&
CMP_OPTIMIZABLE(cmp_opt, Float)) {
5714 return ary_max_opt_float(ary, 1, result);
5717 return ary_max_generic(ary, 1, result);
5726ary_min_generic(
VALUE ary,
long i,
VALUE vmin)
5743ary_min_opt_fixnum(
VALUE ary,
long i,
VALUE vmin)
5750 for (; i < n; ++i) {
5754 if ((
long)vmin > (
long)a) {
5759 return ary_min_generic(ary, i, vmin);
5767ary_min_opt_float(
VALUE ary,
long i,
VALUE vmin)
5774 for (; i < n; ++i) {
5777 if (RB_FLOAT_TYPE_P(a)) {
5783 return ary_min_generic(ary, i, vmin);
5791ary_min_opt_string(
VALUE ary,
long i,
VALUE vmin)
5798 for (; i < n; ++i) {
5807 return ary_min_generic(ary, i, vmin);
5872 return ary_min_opt_fixnum(ary, 1, result);
5875 return ary_min_opt_string(ary, 1, result);
5877 else if (RB_FLOAT_TYPE_P(result) &&
CMP_OPTIMIZABLE(cmp_opt, Float)) {
5878 return ary_min_opt_float(ary, 1, result);
5881 return ary_min_generic(ary, 1, result);
5910rb_ary_minmax(
VALUE ary)
5915 return rb_assoc_new(rb_ary_min(0, 0, ary), rb_ary_max(0, 0, ary));
5953rb_ary_uniq_bang(
VALUE ary)
5958 rb_ary_modify_check(ary);
5962 hash = ary_make_hash_by(ary);
5964 hash = ary_make_hash(ary);
5970 rb_ary_modify_check(ary);
5973 rb_ary_unshare(ary);
5976 ary_resize_capa(ary, hash_size);
5978 ary_recycle_hash(hash);
6004rb_ary_uniq(
VALUE ary)
6013 hash = ary_make_hash_by(ary);
6017 hash = ary_make_hash(ary);
6021 ary_recycle_hash(hash);
6037rb_ary_compact_bang(
VALUE ary)
6054 ary_resize_smaller(ary, n);
6069rb_ary_compact(
VALUE ary)
6072 rb_ary_compact_bang(ary);
6120 rb_warn(
"given block not used");
6131flatten(
VALUE ary,
int level)
6134 VALUE stack, result, tmp = 0, elt, vmemo;
6159 RBASIC_CLEAR_CLASS(vmemo);
6172 if (level >= 0 &&
RARRAY_LEN(stack) / 2 >= level) {
6177 if (
RBASIC(result)->klass) {
6253 int mod = 0, level = -1;
6257 rb_ary_modify_check(ary);
6259 if (level == 0)
return Qnil;
6261 result = flatten(ary, level);
6262 if (result == ary) {
6310 if (level == 0)
return ary_make_shared_copy(ary);
6313 result = flatten(ary, level);
6314 if (result == ary) {
6315 result = ary_make_shared_copy(ary);
6321#define RAND_UPTO(max) (long)rb_random_ulong_limited((randgen), (max)-1)
6349 rb_ary_shuffle_bang(ec, ary, randgen);
6357 long n,
len, i, j, k, idx[10];
6359 long memo_threshold;
6368 return rb_ary_elt(ary, i);
6374 for (i = 0; i < n; ++i) {
6381 for (i = 0; i < n; ++i) {
6403 if (j >= i) l = i,
g = ++j;
6404 if (k >= l && (++k >=
g)) ++k;
6415 sorted[0] = idx[0] = rnds[0];
6416 for (i=1; i<n; i++) {
6418 for (j = 0; j < i; ++j) {
6419 if (k < sorted[j])
break;
6422 memmove(&sorted[j+1], &sorted[j],
sizeof(sorted[0])*(i-j));
6423 sorted[j] = idx[i] = k;
6427 for (i=0; i<n; i++) {
6432 else if (n <= memo_threshold / 2) {
6434#undef RUBY_UNTYPED_DATA_WARNING
6435#define RUBY_UNTYPED_DATA_WARNING 0
6441 for (i=0; i<n; i++) {
6444 if (r > max_idx) max_idx = r;
6447 if (
len <= max_idx) n = 0;
6448 else if (n >
len) n =
len;
6450 for (i=0; i<n; i++) {
6451 long j2 = j = ptr_result[i];
6457 ptr_result[i] = ptr_ary[j2];
6466 RBASIC_CLEAR_CLASS(result);
6469 for (i=0; i<n; i++) {
6472 ptr_result[j] = ptr_result[i];
6476 RBASIC_SET_CLASS_RAW(result,
rb_cArray);
6496 return rb_fix_mul_fix(rb_ary_length(self), n);
6541 if (n <= 0)
return Qnil;
6544 while (
RARRAY_LEN(ary) > 0 && (n < 0 || 0 < n--)) {
6552#define tmpary(n) rb_ary_tmp_new(n)
6553#define tmpary_discard(a) (ary_discard(a), RBASIC_SET_CLASS_RAW(a, rb_cArray))
6561yield_indexed_values(
const VALUE values,
const long r,
const long *
const p)
6566 for (i = 0; i < r; i++) ARY_SET(result, i,
RARRAY_AREF(values, p[i]));
6569 return !
RBASIC(values)->klass;
6585permute0(
const long n,
const long r,
long *
const p,
char *
const used,
const VALUE values)
6587 long i = 0, index = 0;
6590 const char *
const unused = memchr(&used[i], 0, n-i);
6605 for (i = 0; i < n; ++i) {
6606 if (used[i])
continue;
6608 if (!yield_indexed_values(values, r, p)) {
6624descending_factorial(
long from,
long how_many)
6629 while (--how_many > 0) {
6641binomial_coefficient(
long comb,
long size)
6645 if (comb >
size-comb) {
6651 else if (comb == 0) {
6655 for (i = 1; i < comb; ++i) {
6668 return descending_factorial(n, k);
6746 if (r < 0 || n < r) {
6760 char *used = (
char*)(p + r);
6761 VALUE ary0 = ary_make_shared_copy(ary);
6762 RBASIC_CLEAR_CLASS(ary0);
6766 permute0(n, r, p, used, ary0);
6774combinate0(
const long len,
const long n,
long *
const stack,
const VALUE values)
6781 for (lev++; lev < n; lev++) {
6782 stack[lev+1] = stack[lev]+1;
6784 if (!yield_indexed_values(values, n, stack+1)) {
6788 if (lev == 0)
return;
6790 }
while (stack[lev+1]+n ==
len+lev+1);
6800 return binomial_coefficient(k, n);
6853 if (n < 0 ||
len < n) {
6865 VALUE ary0 = ary_make_shared_copy(ary);
6867 long *stack =
ALLOCV_N(
long, t0, n+1);
6869 RBASIC_CLEAR_CLASS(ary0);
6870 combinate0(
len, n, stack, ary0);
6890rpermute0(
const long n,
const long r,
long *
const p,
const VALUE values)
6892 long i = 0, index = 0;
6896 if (++index < r-1) {
6900 for (i = 0; i < n; ++i) {
6902 if (!yield_indexed_values(values, r, p)) {
6907 if (index <= 0)
return;
6908 }
while ((i = ++p[--index]) >= n);
7005 VALUE ary0 = ary_make_shared_copy(ary);
7006 RBASIC_CLEAR_CLASS(ary0);
7008 rpermute0(n, r, p, ary0);
7016rcombinate0(
const long n,
const long r,
long *
const p,
const long rest,
const VALUE values)
7018 long i = 0, index = 0;
7022 if (++index < r-1) {
7026 for (; i < n; ++i) {
7028 if (!yield_indexed_values(values, r, p)) {
7033 if (index <= 0)
return;
7034 }
while ((i = ++p[--index]) >= n);
7046 return binomial_coefficient(k, n + k - 1);
7121 else if (
len == 0) {
7127 VALUE ary0 = ary_make_shared_copy(ary);
7128 RBASIC_CLEAR_CLASS(ary0);
7130 rcombinate0(
len, n, p, n, ary0);
7192 VALUE *arrays = RARRAY_PTR(t0);
7193 int *counters =
ALLOCV_N(
int, t1, n);
7198 RBASIC_CLEAR_CLASS(t0);
7203 for (i = 1; i < n; i++) arrays[i] =
Qnil;
7204 for (i = 1; i < n; i++) arrays[i] =
to_ary(
argv[i-1]);
7207 for (i = 0; i < n; i++) counters[i] = 0;
7212 for (i = 0; i < n; i++) {
7214 arrays[i] = ary_make_shared_copy(arrays[i]);
7219 for (i = 0; i < n; i++) {
7235 for (j = 0; j < n; j++) {
7240 if (
NIL_P(result)) {
7260 while (counters[m] ==
RARRAY_LEN(arrays[m])) {
7263 if (--m < 0)
goto done;
7271 return NIL_P(result) ? ary : result;
7321rb_ary_take_while(
VALUE ary)
7329 return rb_ary_take(ary,
LONG2FIX(i));
7380rb_ary_drop_while(
VALUE ary)
7388 return rb_ary_drop(ary,
LONG2FIX(i));
7430 rb_warn(
"given block not used");
7437 for (i = 0; i <
len; ++i) {
7487 rb_warn(
"given block not used");
7494 for (i = 0; i <
len; ++i) {
7544 rb_warn(
"given block not used");
7551 for (i = 0; i <
len; ++i) {
7606 rb_warn(
"given block not used");
7610 if (result)
return Qfalse;
7616 for (i = 0; i <
len; ++i) {
7618 if (result)
return Qfalse;
7626 if (result)
return Qfalse;
7656 if (!--
argc)
return self;
7662finish_exact_sum(
long n,
VALUE r,
VALUE v,
int z)
7746 v = finish_exact_sum(n, r, v,
argc!=0);
7750 v = finish_exact_sum(n, r, v, i!=0);
7752 if (RB_FLOAT_TYPE_P(e)) {
7762 goto has_float_value;
7767 if (RB_FLOAT_TYPE_P(e))
7794 if (fabs(
f) >= fabs(x))
7807 goto has_some_value;
7819rb_ary_deconstruct(
VALUE ary)
8208#include "array.rbinc"
void rb_mem_clear(VALUE *mem, long size)
VALUE rb_ary_new_from_values(long n, const VALUE *elts)
#define ARY_OWNS_HEAP_P(a)
#define FL_UNSET_EMBED(ary)
VALUE rb_ary_includes(VALUE ary, VALUE item)
#define FL_SET_SHARED(ary)
#define ARY_SHARED_ROOT_REFCNT(ary)
#define ARY_SET_SHARED(ary, value)
void rb_ary_detransient(VALUE ary)
#define ARY_SHARED_P(ary)
VALUE rb_ary_assoc(VALUE ary, VALUE key)
void rb_ary_store(VALUE ary, long idx, VALUE val)
VALUE rb_ary_tmp_new_from_values(VALUE klass, long n, const VALUE *elts)
VALUE rb_check_to_array(VALUE ary)
VALUE rb_ary_reverse(VALUE ary)
#define ARY_INCREASE_PTR(ary, n)
size_t rb_ary_memsize(VALUE ary)
VALUE rb_ary_shift(VALUE ary)
VALUE rb_ary_tmp_new_fill(long capa)
VALUE rb_ary_sort(VALUE ary)
VALUE rb_to_array_type(VALUE ary)
#define tmpary_discard(a)
VALUE rb_get_values_at(VALUE obj, long olen, int argc, const VALUE *argv, VALUE(*func)(VALUE, long))
VALUE rb_ary_resurrect(VALUE ary)
VALUE rb_ary_dup(VALUE ary)
VALUE rb_ary_subseq_step(VALUE ary, long beg, long len, long step)
VALUE rb_ary_aref(int argc, const VALUE *argv, VALUE ary)
VALUE rb_ary_push(VALUE ary, VALUE item)
void rb_ary_free(VALUE ary)
VALUE rb_ary_freeze(VALUE ary)
VALUE rb_ary_each(VALUE ary)
VALUE rb_ary_last(int argc, const VALUE *argv, VALUE ary)
VALUE rb_ary_delete(VALUE ary, VALUE item)
VALUE rb_ary_delete_at(VALUE ary, long pos)
void rb_ary_set_len(VALUE ary, long len)
VALUE rb_ary_aref1(VALUE ary, VALUE arg)
#define ARY_SHARED_ROOT(ary)
#define ARY_SHARED_ROOT_OCCUPIED(ary)
VALUE * rb_ary_ptr_use_start(VALUE ary)
VALUE rb_ary_unshift(VALUE ary, VALUE item)
void rb_ary_modify(VALUE ary)
VALUE rb_ary_replace(VALUE copy, VALUE orig)
#define ARY_SET_SHARED_ROOT_REFCNT(ary, value)
void rb_ary_ptr_use_end(VALUE ary)
#define ARY_SET_HEAP_LEN(ary, n)
#define RARRAY_SHARED_ROOT_FLAG
VALUE rb_ary_to_ary(VALUE obj)
VALUE rb_ary_behead(VALUE ary, long n)
VALUE rb_ary_concat(VALUE x, VALUE y)
#define ARY_SET_EMBED_LEN(ary, n)
VALUE rb_ary_shared_with_p(VALUE ary1, VALUE ary2)
#define ARY_SET_LEN(ary, n)
VALUE rb_ary_new_capa(long capa)
VALUE rb_check_array_type(VALUE ary)
VALUE rb_ary_resize(VALUE ary, long len)
expands or shrinks ary to len elements.
#define ARY_SHARED_ROOT_P(ary)
VALUE rb_ary_pop(VALUE ary)
#define FL_SET_SHARED_ROOT(ary)
VALUE rb_ary_tmp_new(long capa)
VALUE rb_ary_clear(VALUE ary)
VALUE rb_ary_at(VALUE ary, VALUE pos)
void rb_ary_delete_same(VALUE ary, VALUE item)
#define FL_UNSET_SHARED(ary)
#define ARY_SET_CAPA(ary, n)
VALUE rb_ary_plus(VALUE x, VALUE y)
VALUE rb_ary_rotate(VALUE ary, long cnt)
VALUE rb_ary_cmp(VALUE ary1, VALUE ary2)
VALUE rb_ary_to_s(VALUE ary)
VALUE rb_ary_cat(VALUE ary, const VALUE *argv, long len)
void rb_ary_cancel_sharing(VALUE ary)
VALUE rb_ary_entry(VALUE ary, long offset)
#define ARY_INCREASE_LEN(ary, n)
VALUE rb_ary_sort_bang(VALUE ary)
#define ARY_SET_PTR(ary, p)
VALUE rb_assoc_new(VALUE car, VALUE cdr)
VALUE rb_ary_join(VALUE ary, VALUE sep)
VALUE rb_ec_ary_new_from_values(rb_execution_context_t *ec, long n, const VALUE *elts)
VALUE rb_ary_rassoc(VALUE ary, VALUE value)
#define RUBY_ASSERT(expr)
Asserts that the given expression is truthy iff RUBY_DEBUG is truthy.
#define RUBY_ASSERT_ALWAYS(expr)
A variant of RUBY_ASSERT that does not interface with RUBY_DEBUG.
#define rb_category_warn(category,...)
VALUE rb_big_plus(VALUE x, VALUE y)
double rb_big2dbl(VALUE x)
#define MUL_OVERFLOW_LONG_P(a, b)
#define rb_ary_subseq(ary, beg, len)
#define rb_define_method(klass, mid, func, arity)
Defines klass#mid.
#define rb_define_singleton_method(klass, mid, func, arity)
Defines klass.mid.
VALUE rb_int_positive_pow(long x, unsigned long y)
#define USE_DEBUG_COUNTER
#define RB_DEBUG_COUNTER_INC(type)
#define MJIT_FUNC_EXPORTED
VALUE rb_enc_associate(VALUE obj, rb_encoding *enc)
void rb_enc_copy(VALUE obj1, VALUE obj2)
rb_encoding * rb_usascii_encoding(void)
#define rb_cmpint(cmp, a, b)
VALUE rb_nmin_run(VALUE obj, VALUE num, int by, int rev, int ary)
VALUE rb_arithmetic_sequence_beg_len_step(VALUE obj, long *begp, long *lenp, long *stepp, long len, int err)
char str[HTML_ESCAPE_MAX_LEN+1]
#define RSTRING_LEN(string)
void rb_gc_force_recycle(VALUE obj)
void rb_gc_writebarrier_remember(VALUE obj)
void rb_include_module(VALUE klass, VALUE module)
VALUE rb_define_class(const char *name, VALUE super)
Defines a top-level class.
void rb_define_alias(VALUE klass, const char *name1, const char *name2)
Defines an alias of a method.
int rb_scan_args(int argc, const VALUE *argv, const char *fmt,...)
int rb_block_given_p(void)
Determines if the current method is given a block.
void rb_raise(VALUE exc, const char *fmt,...)
void rb_bug(const char *fmt,...)
void rb_warn(const char *fmt,...)
VALUE rb_ensure(VALUE(*b_proc)(VALUE), VALUE data1, VALUE(*e_proc)(VALUE), VALUE data2)
An equivalent to ensure clause.
void rb_warning(const char *fmt,...)
VALUE rb_obj_dig(int argc, VALUE *argv, VALUE self, VALUE notfound)
VALUE rb_cObject
Object class.
int rb_eql(VALUE, VALUE)
Determines if obj1 and obj2 are equal in terms of Object::eql?.
VALUE rb_obj_class(VALUE)
VALUE rb_inspect(VALUE)
Convenient wrapper of Object::inspect.
VALUE rb_check_convert_type_with_id(VALUE, int, const char *, ID)
VALUE rb_convert_type_with_id(VALUE v, int t, const char *nam, ID mid)
double rb_num2dbl(VALUE)
Converts a Numeric object to double.
VALUE rb_equal(VALUE, VALUE)
This function is an optimized version of calling #==.
VALUE rb_obj_is_kind_of(VALUE, VALUE)
Determines if obj is a kind of c.
VALUE rb_obj_freeze(VALUE)
Make the object unmodifiable.
VALUE rb_hash_values(VALUE hash)
void rb_hash_st_table_set(VALUE hash, st_table *st)
int rb_hash_add_new_element(VALUE hash, VALUE key, VALUE val)
int rb_hash_stlike_delete(VALUE hash, st_data_t *pkey, st_data_t *pval)
void rb_hash_foreach(VALUE hash, rb_foreach_func *func, VALUE farg)
VALUE rb_hash_new_with_size(st_index_t size)
VALUE rb_hash_aset(VALUE hash, VALUE key, VALUE val)
int rb_hash_stlike_update(VALUE hash, st_data_t key, st_update_callback_func *func, st_data_t arg)
int rb_hash_stlike_lookup(VALUE hash, st_data_t key, st_data_t *pval)
@ RB_WARN_CATEGORY_DEPRECATED
VALUE rb_funcall(VALUE, ID, int,...)
Calls a method.
VALUE rb_call_super(int, const VALUE *)
Defines RBIMPL_HAS_BUILTIN.
#define RETURN_SIZED_ENUMERATOR(obj, argc, argv, size_fn)
#define RETURN_ENUMERATOR(obj, argc, argv)
#define UNLIMITED_ARGUMENTS
VALUE rb_range_beg_len(VALUE, long *, long *, long, int)
#define rb_hash_uint(h, i)
#define rb_str_new(str, len)
#define rb_usascii_str_new(str, len)
st_index_t rb_hash_start(st_index_t)
void rb_str_set_len(VALUE, long)
VALUE rb_str_buf_new(long)
VALUE rb_check_string_type(VALUE)
#define rb_usascii_str_new_cstr(str)
#define rb_usascii_str_new2
int rb_str_cmp(VALUE, VALUE)
VALUE rb_str_buf_append(VALUE, VALUE)
VALUE rb_obj_as_string(VALUE)
VALUE rb_exec_recursive_paired(VALUE(*)(VALUE, VALUE, int), VALUE, VALUE, VALUE)
VALUE rb_exec_recursive(VALUE(*)(VALUE, VALUE, int), VALUE, VALUE)
int rb_respond_to(VALUE, ID)
void rb_define_alloc_func(VALUE, rb_alloc_func_t)
ID rb_intern(const char *)
void * memmove(void *, const void *, size_t)
void ruby_qsort(void *, const size_t, const size_t, int(*)(const void *, const void *, void *), void *)
Internal header for Array.
#define RARRAY_PTR_IN_USE_FLAG
Internal header for Comparable.
#define CMP_OPTIMIZABLE(data, type)
Internal header for Enumerable.
#define SIZED_REALLOC_N(v, T, m, n)
#define RB_EC_NEWOBJ_OF(ec, var, T, c, f)
Internal header for Hash.
Internal header for Numeric.
VALUE rb_fix_plus(VALUE x, VALUE y)
int rb_float_cmp(VALUE x, VALUE y)
VALUE rb_int_idiv(VALUE x, VALUE y)
VALUE rb_int_mul(VALUE x, VALUE y)
Internal header for Object.
Internal header for Proc.
Internal header for Rational.
VALUE rb_rational_plus(VALUE self, VALUE other)
Internal header for RubyVM.
VALUE rb_check_block_call(VALUE, ID, int, const VALUE *, rb_block_call_func_t, VALUE)
#define RUBY_DTRACE_CREATE_HOOK(name, arg)
VALUE rb_yield_force_blockarg(VALUE values)
#define rb_ary_new_from_args(...)
typedef long(ZCALLBACK *tell_file_func) OF((voidpf opaque
#define RB_BLOCK_CALL_FUNC_ARGLIST(yielded_arg, callback_arg)
VALUE rb_yield_values(int n,...)
VALUE rb_yield_values2(int n, const VALUE *argv)
#define RBIMPL_ATTR_MAYBE_UNUSED()
Wraps (or simulates) [[maybe_unused]]
#define MEMCPY(p1, p2, type, n)
#define MEMZERO(p, type, n)
#define MEMMOVE(p1, p2, type, n)
VALUE rb_block_call(VALUE q, ID w, int e, const VALUE *r, type *t, VALUE y)
Call a method with a block.
#define RARRAY_CONST_PTR(s)
#define RARRAY_AREF(a, i)
#define RARRAY_EMBED_FLAG
#define RARRAY_TRANSIENT_FLAG
#define RARRAY_CONST_PTR_TRANSIENT
#define RARRAY_PTR_USE(ary, ptr_name, expr)
#define RARRAY_EMBED_LEN_MAX
#define RARRAY_EMBED_LEN_MASK
#define RARRAY_PTR_USE_TRANSIENT(ary, ptr_name, expr)
#define Data_Wrap_Struct(klass, mark, free, sval)
#define RGENGC_WB_PROTECTED_ARRAY
#define RB_OBJ_WRITE(a, slot, b)
WB for new reference from ‘a’ to ‘b’.
#define RB_OBJ_WB_UNPROTECT_FOR(type, obj)
#define RB_OBJ_WRITTEN(a, oldv, b)
WB for new reference from ‘a’ to ‘b’.
rb_atomic_t cnt[RUBY_NSIG]
#define st_init_numtable_with_size
#define st_is_member(table, key)
struct cmp_opt_data cmp_opt
#define rb_transient_heap_verify()
#define rb_ary_transient_heap_evacuate(x, y)
#define rb_transient_heap_alloc(o, s)
#define smaller(tree, n, m, depth)