mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
add macro ARY_SET_SHARED
This commit is contained in:
+3
-2
@@ -16,6 +16,7 @@
|
||||
#define ARY_C_MAX_SIZE (SIZE_MAX / sizeof(mrb_value))
|
||||
#define ARY_MAX_SIZE ((ARY_C_MAX_SIZE < (size_t)MRB_INT_MAX) ? (mrb_int)ARY_C_MAX_SIZE : MRB_INT_MAX-1)
|
||||
#define ARY_SHARED_P(a) ((a)->flags & MRB_ARY_SHARED)
|
||||
#define ARY_SET_SHARED(a) ((a)->flags |= MRB_ARY_SHARED)
|
||||
|
||||
static inline mrb_value
|
||||
ary_elt(mrb_value ary, mrb_int offset)
|
||||
@@ -173,7 +174,7 @@ ary_make_shared(mrb_state *mrb, struct RArray *a)
|
||||
}
|
||||
shared->len = a->len;
|
||||
a->aux.shared = shared;
|
||||
a->flags |= MRB_ARY_SHARED;
|
||||
ARY_SET_SHARED(a);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -671,7 +672,7 @@ ary_subseq(mrb_state *mrb, struct RArray *a, mrb_int beg, mrb_int len)
|
||||
b->len = len;
|
||||
b->aux.shared = a->aux.shared;
|
||||
b->aux.shared->refcnt++;
|
||||
b->flags |= MRB_ARY_SHARED;
|
||||
ARY_SET_SHARED(b);
|
||||
|
||||
return mrb_obj_value(b);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user