ruby-changes:73943
From: Nobuyoshi <ko1@a...>
Date: Mon, 10 Oct 2022 13:22:19 +0900 (JST)
Subject: [ruby-changes:73943] 0a98dd1cff (master): Should use dedecated function `Check_Type`
https://git.ruby-lang.org/ruby.git/commit/?id=0a98dd1cff From 0a98dd1cffe09c2c17e60e1a1c75bad7e4337002 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada <nobu@r...> Date: Mon, 10 Oct 2022 13:21:57 +0900 Subject: Should use dedecated function `Check_Type` --- re.c | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/re.c b/re.c index ff9d5bccc4..4d0dcf95cc 100644 --- a/re.c +++ b/re.c @@ -2393,12 +2393,7 @@ match_deconstruct_keys(VALUE match, VALUE keys) https://github.com/ruby/ruby/blob/trunk/re.c#L2393 return h; } - if (UNLIKELY(!RB_TYPE_P(keys, T_ARRAY))) { - rb_raise(rb_eTypeError, - "wrong argument type %"PRIsVALUE" (expected Array or nil)", - rb_obj_class(keys)); - - } + Check_Type(keys, T_ARRAY); if (onig_number_of_names(RREGEXP_PTR(RMATCH(match)->regexp)) < RARRAY_LEN(keys)) { return rb_hash_new_with_size(0); @@ -2410,11 +2405,7 @@ match_deconstruct_keys(VALUE match, VALUE keys) https://github.com/ruby/ruby/blob/trunk/re.c#L2405 VALUE key = RARRAY_AREF(keys, i); VALUE name; - if (UNLIKELY(!SYMBOL_P(key))) { - rb_raise(rb_eTypeError, - "wrong argument type %"PRIsVALUE" (expected Symbol)", - rb_obj_class(key)); - } + Check_Type(key, T_SYMBOL); name = rb_sym2str(key); @@ -2423,7 +2414,8 @@ match_deconstruct_keys(VALUE match, VALUE keys) https://github.com/ruby/ruby/blob/trunk/re.c#L2414 if (num >= 0) { rb_hash_aset(h, key, rb_reg_nth_match(num, match)); - } else { + } + else { return h; } } -- cgit v1.2.1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/