ruby-changes:54589
From: nobu <ko1@a...>
Date: Sun, 13 Jan 2019 13:36:50 +0900 (JST)
Subject: [ruby-changes:54589] nobu:r66804 (trunk): time.c: separate sign argument
nobu 2019-01-13 13:36:45 +0900 (Sun, 13 Jan 2019) New Revision: 66804 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=66804 Log: time.c: separate sign argument * time.c (vtm_add_offset): separate sign argument to get rid of repeated negations. Modified files: trunk/time.c Index: time.c =================================================================== --- time.c (revision 66803) +++ time.c (revision 66804) @@ -1904,20 +1904,16 @@ time_set_utc_offset(VALUE time, VALUE of https://github.com/ruby/ruby/blob/trunk/time.c#L1904 } static void -vtm_add_offset(struct vtm *vtm, VALUE off) +vtm_add_offset(struct vtm *vtm, VALUE off, int sign) { - int sign; VALUE subsec, v; int sec, min, hour; int day; if (lt(off, INT2FIX(0))) { - sign = -1; + sign = -sign; off = neg(off); } - else { - sign = 1; - } divmodv(off, INT2FIX(1), &off, &subsec); divmodv(off, INT2FIX(60), &off, &v); sec = NUM2INT(v); @@ -2338,7 +2334,7 @@ time_init_1(int argc, VALUE *argv, VALUE https://github.com/ruby/ruby/blob/trunk/time.c#L2334 if (!NIL_P(vtm.utc_offset)) { VALUE off = vtm.utc_offset; - vtm_add_offset(&vtm, neg(off)); + vtm_add_offset(&vtm, off, -1); vtm.utc_offset = Qnil; tobj->timew = timegmw(&vtm); return time_set_utc_offset(time, off); @@ -3891,7 +3887,7 @@ time_fixoff(VALUE time) https://github.com/ruby/ruby/blob/trunk/time.c#L3887 zone = tobj->vtm.zone; tobj->vtm = vtm; tobj->vtm.zone = zone; - vtm_add_offset(&tobj->vtm, off); + vtm_add_offset(&tobj->vtm, off, +1); tobj->tm_got = 1; TZMODE_SET_FIXOFF(tobj, off); -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/