Should use dedecated function Check_Type

This commit is contained in:
Nobuyoshi Nakada 2022-10-10 13:21:57 +09:00
parent 4954c9fc0f
commit 0a98dd1cff
No known key found for this signature in database
GPG Key ID: 7CD2805BFA3770C6

16
re.c
View File

@ -2393,12 +2393,7 @@ match_deconstruct_keys(VALUE match, VALUE keys)
return h; return h;
} }
if (UNLIKELY(!RB_TYPE_P(keys, T_ARRAY))) { Check_Type(keys, T_ARRAY);
rb_raise(rb_eTypeError,
"wrong argument type %"PRIsVALUE" (expected Array or nil)",
rb_obj_class(keys));
}
if (onig_number_of_names(RREGEXP_PTR(RMATCH(match)->regexp)) < RARRAY_LEN(keys)) { if (onig_number_of_names(RREGEXP_PTR(RMATCH(match)->regexp)) < RARRAY_LEN(keys)) {
return rb_hash_new_with_size(0); return rb_hash_new_with_size(0);
@ -2410,11 +2405,7 @@ match_deconstruct_keys(VALUE match, VALUE keys)
VALUE key = RARRAY_AREF(keys, i); VALUE key = RARRAY_AREF(keys, i);
VALUE name; VALUE name;
if (UNLIKELY(!SYMBOL_P(key))) { Check_Type(key, T_SYMBOL);
rb_raise(rb_eTypeError,
"wrong argument type %"PRIsVALUE" (expected Symbol)",
rb_obj_class(key));
}
name = rb_sym2str(key); name = rb_sym2str(key);
@ -2423,7 +2414,8 @@ match_deconstruct_keys(VALUE match, VALUE keys)
if (num >= 0) { if (num >= 0) {
rb_hash_aset(h, key, rb_reg_nth_match(num, match)); rb_hash_aset(h, key, rb_reg_nth_match(num, match));
} else { }
else {
return h; return h;
} }
} }