[前][次][番号順一覧][スレッド一覧]

ruby-changes:59695

From: John <ko1@a...>
Date: Tue, 14 Jan 2020 06:58:50 +0900 (JST)
Subject: [ruby-changes:59695] 5f3189474c (master): Avoid rb_check_string_type in month_arg

https://git.ruby-lang.org/ruby.git/commit/?id=5f3189474c

From 5f3189474c3ee3e11b6588acfbb026e119522092 Mon Sep 17 00:00:00 2001
From: John Hawthorn <john@h...>
Date: Thu, 2 Jan 2020 11:48:03 -0800
Subject: 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.

diff --git a/time.c b/time.c
index fbccc90..817b6ef 100644
--- a/time.c
+++ b/time.c
@@ -2923,6 +2923,10 @@ month_arg(VALUE arg) https://github.com/ruby/ruby/blob/trunk/time.c#L2923
 {
     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;
-- 
cgit v0.10.2


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]