Skip to content

Commit

Permalink
Add RARRAY_SHARED_FLAG
Browse files Browse the repository at this point in the history
  • Loading branch information
peterzhu2118 committed Jul 21, 2022
1 parent 1c9acb6 commit d67fcdc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
6 changes: 3 additions & 3 deletions array.c
Expand Up @@ -66,7 +66,7 @@ should_be_T_ARRAY(VALUE ary)
#define ARY_HEAP_SIZE(a) (assert(!ARY_EMBED_P(a)), assert(ARY_OWNS_HEAP_P(a)), ARY_CAPA(a) * sizeof(VALUE))

#define ARY_OWNS_HEAP_P(a) (assert(should_be_T_ARRAY((VALUE)(a))), \
!FL_TEST_RAW((a), ELTS_SHARED|RARRAY_EMBED_FLAG))
!FL_TEST_RAW((a), RARRAY_SHARED_FLAG|RARRAY_EMBED_FLAG))

#define FL_SET_EMBED(a) do { \
assert(!ARY_SHARED_P(a)); \
Expand All @@ -78,9 +78,9 @@ should_be_T_ARRAY(VALUE ary)
#define FL_UNSET_EMBED(ary) FL_UNSET((ary), RARRAY_EMBED_FLAG|RARRAY_EMBED_LEN_MASK)
#define FL_SET_SHARED(ary) do { \
assert(!ARY_EMBED_P(ary)); \
FL_SET((ary), ELTS_SHARED); \
FL_SET((ary), RARRAY_SHARED_FLAG); \
} while (0)
#define FL_UNSET_SHARED(ary) FL_UNSET((ary), ELTS_SHARED)
#define FL_UNSET_SHARED(ary) FL_UNSET((ary), RARRAY_SHARED_FLAG)

#define ARY_SET_PTR(ary, p) do { \
assert(!ARY_EMBED_P(ary)); \
Expand Down
5 changes: 3 additions & 2 deletions internal/array.h
Expand Up @@ -18,6 +18,7 @@
# define ARRAY_DEBUG (0+RUBY_DEBUG)
#endif

#define RARRAY_SHARED_FLAG ELTS_SHARED
#define RARRAY_SHARED_ROOT_FLAG FL_USER12
#define RARRAY_PTR_IN_USE_FLAG FL_USER14
#define RARRAY_LITERAL_FLAG FL_USER15
Expand Down Expand Up @@ -79,15 +80,15 @@ RBIMPL_ATTR_MAYBE_UNUSED()
static inline int
ary_should_not_be_shared_and_embedded(VALUE ary)
{
return !FL_ALL_RAW(ary, ELTS_SHARED|RARRAY_EMBED_FLAG);
return !FL_ALL_RAW(ary, RARRAY_SHARED_FLAG|RARRAY_EMBED_FLAG);
}

static inline bool
ARY_SHARED_P(VALUE ary)
{
assert(RB_TYPE_P(ary, T_ARRAY));
assert(ary_should_not_be_shared_and_embedded(ary));
return FL_TEST_RAW(ary, ELTS_SHARED);
return FL_TEST_RAW(ary, RARRAY_SHARED_FLAG);
}

static inline bool
Expand Down

0 comments on commit d67fcdc

Please sign in to comment.