summaryrefslogtreecommitdiff
path: root/time.c
diff options
context:
space:
mode:
authorJohn Hawthorn <john@hawthorn.email>2020-01-02 11:48:03 -0800
committerAaron Patterson <tenderlove@github.com>2020-01-13 13:58:23 -0800
commit5f3189474c3ee3e11b6588acfbb026e119522092 (patch)
tree9547c3c2682e4d9087fccebe4c7758f9ba9dcd7f /time.c
parentc2e45422f7abc9836d3b68bb94e527b3aad9bfd7 (diff)
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.
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/2808
Diffstat (limited to 'time.c')
-rw-r--r--time.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/time.c b/time.c
index fbccc9078d..817b6ef101 100644
--- a/time.c
+++ b/time.c
@@ -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;