Avoid rb_check_string_type in month_arg

This will usually receive a fixnum so we should check that first instead
of the more expensive rb_check_string_type check.
This commit is contained in:
John Hawthorn 2020-01-02 11:48:03 -08:00 committed by Aaron Patterson
parent c2e45422f7
commit 5f3189474c
Notes: git 2020-01-14 06:58:59 +09:00

4
time.c
View File

@ -2923,6 +2923,10 @@ month_arg(VALUE arg)
{
int i, mon;
if (FIXNUM_P(arg)) {
return obj2ubits(arg, 4);
}
VALUE s = rb_check_string_type(arg);
if (!NIL_P(s) && RSTRING_LEN(s) > 0) {
mon = 0;