From 4c875b6e667d205fef5533670460e2043c9aaa6a Mon Sep 17 00:00:00 2001 From: nobu Date: Thu, 25 Oct 2018 00:36:23 +0000 Subject: [PATCH] time.c: benchmark recovery * time.c (time_localtime): check if `vtm.zone` is a simple zone name string before trying to call the conversion method. since r64952, `Time.getlocal` on UTC time has lost the performance about 45%, due to this call. the performance is about 90% of r64951 by avoiding it. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65360 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- time.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/time.c b/time.c index f801ee5ac1..dc4a8dbd4d 100644 --- a/time.c +++ b/time.c @@ -3623,6 +3623,7 @@ time_localtime(VALUE time) { struct time_object *tobj; struct vtm vtm; + VALUE zone; GetTimeval(time, tobj); if (TZMODE_LOCALTIME_P(tobj)) { @@ -3633,7 +3634,8 @@ time_localtime(VALUE time) time_modify(time); } - if (!NIL_P(tobj->vtm.zone) && zone_localtime(tobj->vtm.zone, time)) { + zone = tobj->vtm.zone; + if (maybe_tzobj_p(zone) && zone_localtime(zone, time)) { return time; }