Assume that shared_root exists in rb_ary_decrement_share

All callers of rb_ary_decrement_share guarantee that
shared_root is not 0.
This commit is contained in:
Peter Zhu 2022-03-14 09:39:51 -04:00
parent 7348db866a
commit 45786667ec

View File

@ -512,11 +512,9 @@ ary_double_capa(VALUE ary, long min)
static void static void
rb_ary_decrement_share(VALUE shared_root) rb_ary_decrement_share(VALUE shared_root)
{ {
if (shared_root) { long num = ARY_SHARED_ROOT_REFCNT(shared_root) - 1;
long num = ARY_SHARED_ROOT_REFCNT(shared_root) - 1; if (num > 0) {
if (num > 0) { ARY_SET_SHARED_ROOT_REFCNT(shared_root, num);
ARY_SET_SHARED_ROOT_REFCNT(shared_root, num);
}
} }
} }