ruby-changes:71411
From: Peter <ko1@a...>
Date: Mon, 14 Mar 2022 22:46:25 +0900 (JST)
Subject: [ruby-changes:71411] 45786667ec (master): Assume that shared_root exists in rb_ary_decrement_share
https://git.ruby-lang.org/ruby.git/commit/?id=45786667ec From 45786667ec0b0c2af5bf2c2069246edaae2d7c30 Mon Sep 17 00:00:00 2001 From: Peter Zhu <peter@p...> Date: Mon, 14 Mar 2022 09:39:51 -0400 Subject: Assume that shared_root exists in rb_ary_decrement_share All callers of rb_ary_decrement_share guarantee that shared_root is not 0. --- array.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/array.c b/array.c index ae2ba38cbe..53e69f2a32 100644 --- a/array.c +++ b/array.c @@ -512,11 +512,9 @@ ary_double_capa(VALUE ary, long min) https://github.com/ruby/ruby/blob/trunk/array.c#L512 static void rb_ary_decrement_share(VALUE shared_root) { - if (shared_root) { - long num = ARY_SHARED_ROOT_REFCNT(shared_root) - 1; - if (num > 0) { - ARY_SET_SHARED_ROOT_REFCNT(shared_root, num); - } + long num = ARY_SHARED_ROOT_REFCNT(shared_root) - 1; + if (num > 0) { + ARY_SET_SHARED_ROOT_REFCNT(shared_root, num); } } -- cgit v1.2.1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/